You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,7 +124,7 @@ You can find our backwards-compatibility policy [here](https://github.com/hynek/
124
124
125
125
### Deprecated
126
126
127
-
- Accessing package metadata as attributes on the *structlog* module is deprecated (e.g.`structlog.__version__`).
127
+
- Accessing package metadata as attributes on the *structlog* module is deprecated (for example,`structlog.__version__`).
128
128
Please use [`importlib.metadata`](https://docs.python.org/3.10/library/importlib.metadata.html) instead (for Python 3.7: the [*importlib-metadata*](https://pypi.org/project/importlib-metadata/) PyPI package).
129
129
- The `structlog.types` module is now deprecated in favor of the `structlog.typing` module.
130
130
It seems like the Python typing community is settling on this name.
@@ -277,7 +277,7 @@ You can find our backwards-compatibility policy [here](https://github.com/hynek/
277
277
-*structlog* switched its packaging to [*flit*](https://flit.pypa.io/).
278
278
Users shouldn't notice a difference, but (re-)packagers might.
279
279
-`structlog.stdlib.AsyncBoundLogger` now determines the running loop when logging, not on instantiation.
280
-
That has a minor performance impact, but makes it more robust when loops change (e.g.`aiohttp.web.run_app()`), or you want to use `sync_bl`*before* a loop has started.
280
+
That has a minor performance impact, but makes it more robust when loops change (for example,`aiohttp.web.run_app()`), or you want to use `sync_bl`*before* a loop has started.
281
281
282
282
283
283
### Fixed
@@ -331,7 +331,7 @@ You can find our backwards-compatibility policy [here](https://github.com/hynek/
331
331
332
332
### Fixed
333
333
334
-
-*structlog* is now importable if `sys.stdout` is `None` (e.g. when running using `pythonw`). [#313](https://github.com/hynek/structlog/issues/313)
334
+
-*structlog* is now importable if `sys.stdout` is `None` (for example, when running using `pythonw`). [#313](https://github.com/hynek/structlog/issues/313)
@@ -372,7 +372,7 @@ You can find our backwards-compatibility policy [here](https://github.com/hynek/
372
372
-*structlog* has now type hints for all of its APIs!
373
373
Since *structlog* is highly dynamic and configurable, this led to a few concessions like a specialized `structlog.stdlib.get_logger()` whose only difference to `structlog.get_logger()` is that it has the correct type hints.
374
374
375
-
We consider them provisional for the time being – i.e. the backwards-compatibility does not apply to them in its full strength until we feel we got it right.
375
+
We consider them provisional for the time being – that means the backwards-compatibility does not apply to them in its full strength until we feel we got it right.
Copy file name to clipboardExpand all lines: docs/bound-loggers.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,7 +153,7 @@ You will configure *structlog* as explained in the {doc}`next chapter <configura
153
153
154
154
However, in some rare cases you may not want to do that.
155
155
For example because you don't control how you get the logger that you would like to wrap (famous example: Celery).
156
-
For that times there is the {func}`structlog.wrap_logger` function that can be used to wrap a logger -- optionally without any global state (i.e. configuration):
156
+
For that times there is the {func}`structlog.wrap_logger` function that can be used to wrap a logger -- optionally without any global state (in other words, configuration):
Copy file name to clipboardExpand all lines: docs/contextvars.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ event='hi there' a=None
85
85
86
86
## Support for `contextvars.Token`
87
87
88
-
If e.g. your request handler calls a helper function that needs to temporarily override some contextvars before restoring them back to their original values, you can use the {class}`~contextvars.Token`s returned by {func}`~structlog.contextvars.bind_contextvars` along with {func}`~structlog.contextvars.reset_contextvars` to accomplish this (much like how {meth}`contextvars.ContextVar.reset` works):
88
+
If, for example, your request handler calls a helper function that needs to temporarily override some contextvars before restoring them back to their original values, you can use the {class}`~contextvars.Token`s returned by {func}`~structlog.contextvars.bind_contextvars` along with {func}`~structlog.contextvars.reset_contextvars` to accomplish this (much like how {meth}`contextvars.ContextVar.reset` works):
Copy file name to clipboardExpand all lines: docs/processors.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,8 @@
1
1
# Processors
2
2
3
3
The true power of *structlog* lies in its *combinable log processors*.
4
-
A log processor is a regular callable, i.e. a function or an instance of a class with a `__call__()` method.
4
+
A log processor is a regular callable or in other words:
5
+
A function or an instance of a class with a `__call__()` method.
5
6
6
7
(chains)=
7
8
@@ -29,7 +30,7 @@ The return value of each processor is passed on to the next one as `event_dict`
29
30
30
31
:::{note}
31
32
*structlog* only looks at the return value of the **last** processor.
32
-
That means that as long as you control the next processor in the chain (i.e. the processor that will get your return value passed as an argument), you can return whatever you want.
33
+
That means that as long as you control the next processor in the chain (the processor that will get your return value passed as an argument), you can return whatever you want.
33
34
34
35
Returning a modified event dictionary from your processors is just a convention to make processors composable.
35
36
:::
@@ -95,7 +96,7 @@ But we can do better than that!
95
96
96
97
(cond-drop)=
97
98
98
-
How about dropping only log entries that are marked as coming from a certain peer (e.g. monitoring)?
99
+
How about dropping only log entries that are marked as coming from a certain peer (for example, monitoring)?
Copy file name to clipboardExpand all lines: docs/standard-library.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ logging.basicConfig(
30
30
)
31
31
```
32
32
33
-
This will send all log messages with the [log level](https://docs.python.org/3/library/logging.html#logging-levels)`logging.INFO` and above (that means that e.g.`logging.debug` calls are ignored) to standard out without any special formatting by the standard library.
33
+
This will send all log messages with the [log level](https://docs.python.org/3/library/logging.html#logging-levels)`logging.INFO` and above (that means that, for example,`logging.debug` calls are ignored) to standard out without any special formatting by the standard library.
34
34
35
35
If you require more complex behavior, please refer to the standard library's `logging` documentation.
36
36
@@ -63,13 +63,14 @@ This means an increased computational cost per log entry, but your application w
63
63
---
64
64
65
65
66
-
*structlog* also comes with {class}`structlog.stdlib.AsyncBoundLogger` that blankly makes all logging methods asynchronous (i.e. `await log.info()`).
66
+
*structlog* also comes with {class}`structlog.stdlib.AsyncBoundLogger` that blankly makes all logging methods asynchronous (in other words, you have to use `await log.info()` instead of just `log.info()`).
67
67
68
68
To use it, {doc}`configure <configuration>`*structlog* to use `AsyncBoundLogger` as `wrapper_class`.
69
69
70
70
```{versionadded} 20.2.0
71
71
```
72
-
72
+
```{deprecated} 23.1.0
73
+
```
73
74
74
75
75
76
## Processors
@@ -118,7 +119,7 @@ To use it, {doc}`configure <configuration>` *structlog* to use `AsyncBoundLogger
: This processes and formats positional arguments (if any) passed to log methods in the same way the `logging` module would do, e.g.`logger.info("Hello, %s", name)`.
122
+
: This processes and formats positional arguments (if any) passed to log methods in the same way the `logging` module would do, for example,`logger.info("Hello, %s", name)`.
122
123
123
124
*structlog* also comes with {class}`~structlog.stdlib.ProcessorFormatter` which is a `logging.Formatter` that enables you to format non-*structlog* log entries using *structlog* renderers *and* multiplex *structlog*’s output with different renderers (see [below](processor-formatter) for an example).
124
125
@@ -285,7 +286,7 @@ structlog.configure(
285
286
```
286
287
287
288
Now you have the event dict available within each log record.
288
-
If you want all your log entries (i.e. also those not from your application / *structlog*) to be formatted as JSON, you can use the [*python-json-logger*] library:
289
+
If you want *all* your log entries (meaning: also those not from your application / *structlog*) to be formatted as JSON, you can use the [*python-json-logger*] library:
Of course, you probably want timestamps and log levels in your output.
396
-
The `ProcessorFormatter` has a `foreign_pre_chain` argument which is responsible for adding properties to events from the standard library -- i.e. that do not originate from a *structlog* logger -- and which should in general match the `processors` argument to {func}`structlog.configure` so you get a consistent output.
397
+
The `ProcessorFormatter` has a `foreign_pre_chain` argument which is responsible for adding properties to events from the standard library -- in other words, those that do not originate from a *structlog* logger -- and which should in general match the `processors` argument to {func}`structlog.configure` so you get a consistent output.
397
398
398
399
`_from_structlog` and `_record` allow your processors to determine whether the log entry is coming from *structlog*, and to extract information from `logging.LogRecord`s and add them to the event dictionary.
399
400
However, you probably don't want to have them in your log files, thus we've added the `ProcessorFormatter.remove_processors_meta` processor to do so conveniently.
You can also bind key-value pairs to {doc}`context variables <contextvars>` that look global, but are local to your thread or *asyncio* context (i.e. usually your request).
56
+
You can also bind key-value pairs to {doc}`context variables <contextvars>` that look global, but are local to your thread or *asyncio* context -- which usually means your web request.
0 commit comments