Skip to content

Commit 0c26f34

Browse files
authored
Release 0.3
1 parent b6555c7 commit 0c26f34

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## 0.3 (2020-07-27)
4+
5+
- Added collecting `LogRecord.exc_info` into `error.*` fields
6+
automatically for `StdlibFormatter` ([#16](https://github.com/elastic/ecs-logging-python/pull/16))
7+
- Added collecting process and thread info from `LogRecord` into `process.*` fields
8+
automatically for `StdlibFormatter` ([#16](https://github.com/elastic/ecs-logging-python/pull/16))
9+
- Added `exclude_fields` parameter to `StdlibFormatter` to
10+
exclude fields from being formatted to JSON ([#16](https://github.com/elastic/ecs-logging-python/pull/16))
11+
- Added `stack_trace_limit` parameter to `StdlibFormatter`
12+
to control the number of stack trace frames being
13+
formatted in `error.stack_trace` ([#16](https://github.com/elastic/ecs-logging-python/pull/16))
14+
15+
Thanks to community contributor Jon Moore ([@comcast-jonm](https://github.com/comcast-jonm))
16+
for their contributions to this release.
17+
318
## 0.2 (2020-04-28)
419

520
- Added support for using `log(..., extra={...})` on standard library

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ we will be following (ECS.major).(ECS.minor).(package minor) as our versioning s
1717
## Installation
1818

1919
```console
20-
python -m pip install ecs-logging
20+
$ python -m pip install ecs-logging
2121
```
2222

2323
## Getting Started
@@ -71,6 +71,46 @@ logger.debug("Example message!", extra={"http.request.method": "get"})
7171
}
7272
```
7373

74+
##### Excluding Fields
75+
76+
You can exclude fields from being collected by using the `exclude_fields` option
77+
in the `StdlibFormatter` constructor:
78+
79+
```python
80+
from ecs_logging import StdlibFormatter
81+
82+
formatter = StdlibFormatter(
83+
exclude_fields=[
84+
# You can specify individual fields to ignore:
85+
"log.original",
86+
# or you can also use prefixes to ignore
87+
# whole categories of fields:
88+
"process",
89+
"log.origin",
90+
]
91+
)
92+
```
93+
94+
##### Limiting Stack Traces
95+
96+
The `StdlibLogger` automatically gathers `exc_info` into ECS `error.*` fields.
97+
If you'd like to control the number of stack frames that are included
98+
in `error.stack_trace` you can use the `stack_trace_limit` parameter
99+
(by default all frames are collected):
100+
101+
```python
102+
from ecs_logging import StdlibFormatter
103+
104+
formatter = StdlibFormatter(
105+
# Only collects 3 stack frames
106+
stack_trace_limit=3,
107+
)
108+
formatter = StdlibFormatter(
109+
# Disable stack trace collection
110+
stack_trace_limit=0,
111+
)
112+
```
113+
74114
### Structlog Example
75115

76116
```python

ecs_logging/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ._stdlib import StdlibFormatter
55
from ._structlog import StructlogFormatter
66

7-
__version__ = "0.2"
7+
__version__ = "0.3"
88
__all__ = [
99
"ECS_VERSION",
1010
"StdlibFormatter",

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ classifiers = [
1919
"Programming Language :: Python :: 3.6",
2020
"Programming Language :: Python :: 3.7",
2121
"Programming Language :: Python :: 3.8",
22+
"Programming Language :: Python :: 3.9",
2223
"Topic :: System :: Logging",
2324
"License :: OSI Approved :: Apache Software License"
2425
]

0 commit comments

Comments
 (0)