@@ -81,7 +81,7 @@ def is_configured() -> bool:
81
81
82
82
If `False`, *structlog* is running with builtin defaults.
83
83
84
- .. versionadded: 18.1
84
+ .. versionadded: 18.1.0
85
85
"""
86
86
return _CONFIG .is_configured
87
87
@@ -94,7 +94,7 @@ def get_config() -> dict[str, Any]:
94
94
95
95
Changes to the returned dictionary do *not* affect *structlog*.
96
96
97
- .. versionadded: 18.1
97
+ .. versionadded: 18.1.0
98
98
"""
99
99
return {
100
100
"processors" : _CONFIG .default_processors ,
@@ -114,12 +114,18 @@ def get_logger(*args: Any, **initial_values: Any) -> Any:
114
114
>>> log.info("hello", x=42)
115
115
y=23 x=42 event='hello'
116
116
117
- :param args: *Optional* positional arguments that are passed unmodified to
118
- the logger factory. Therefore it depends on the factory what they
119
- mean.
120
- :param initial_values: Values that are used to pre-populate your contexts.
117
+ Arguments:
121
118
122
- :returns: A proxy that creates a correctly configured bound logger when
119
+ args:
120
+ *Optional* positional arguments that are passed unmodified to the
121
+ logger factory. Therefore it depends on the factory what they
122
+ mean.
123
+
124
+ initial_values: Values that are used to pre-populate your contexts.
125
+
126
+ Returns:
127
+
128
+ A proxy that creates a correctly configured bound logger when
123
129
necessary. The type of that bound logger depends on your configuration
124
130
and is `structlog.BoundLogger` by default.
125
131
@@ -128,8 +134,7 @@ def get_logger(*args: Any, **initial_values: Any) -> Any:
128
134
If you prefer CamelCase, there's an alias for your reading pleasure:
129
135
`structlog.getLogger`.
130
136
131
- .. versionadded:: 0.4.0
132
- *args*
137
+ .. versionadded:: 0.4.0 *args*
133
138
"""
134
139
return wrap_logger (None , logger_factory_args = args , ** initial_values )
135
140
@@ -158,23 +163,28 @@ def wrap_logger(
158
163
Default values for *processors*, *wrapper_class*, and *context_class* can
159
164
be set using `configure`.
160
165
161
- If you set an attribute here, `configure` calls have *no* effect for
162
- the *respective* attribute.
166
+ If you set an attribute here, `configure` calls have *no* effect for the
167
+ *respective* attribute.
163
168
164
169
In other words: selective overwriting of the defaults while keeping some
165
170
*is* possible.
166
171
167
- :param initial_values: Values that are used to pre-populate your contexts.
168
- :param logger_factory_args: Values that are passed unmodified as
169
- ``*logger_factory_args`` to the logger factory if not `None` .
172
+ Arguments:
173
+
174
+ initial_values: Values that are used to pre-populate your contexts .
170
175
171
- :returns: A proxy that creates a correctly configured bound logger when
176
+ logger_factory_args:
177
+ Values that are passed unmodified as ``*logger_factory_args`` to
178
+ the logger factory if not `None`.
179
+
180
+ Returns:
181
+
182
+ A proxy that creates a correctly configured bound logger when
172
183
necessary.
173
184
174
185
See `configure` for the meaning of the rest of the arguments.
175
186
176
- .. versionadded:: 0.4.0
177
- *logger_factory_args*
187
+ .. versionadded:: 0.4.0 *logger_factory_args*
178
188
"""
179
189
return BoundLoggerLazyProxy (
180
190
logger ,
@@ -207,22 +217,29 @@ def configure(
207
217
208
218
Use `reset_defaults` to undo your changes.
209
219
210
- :param processors: The processor chain. See :doc:`processors` for details.
211
- :param wrapper_class: Class to use for wrapping loggers instead of
212
- `structlog.BoundLogger`. See `standard-library`, :doc:`twisted`, and
213
- `custom-wrappers`.
214
- :param context_class: Class to be used for internal context keeping. The
215
- default is a `dict` and since dictionaries are ordered as of Python
216
- 3.6, there's few reasons to change this option.
217
- :param logger_factory: Factory to be called to create a new logger that
218
- shall be wrapped.
219
- :param cache_logger_on_first_use: `wrap_logger` doesn't return an actual
220
- wrapped logger but a proxy that assembles one when it's first used. If
221
- this option is set to `True`, this assembled logger is cached. See
222
- `performance`.
223
-
224
- .. versionadded:: 0.3.0
225
- *cache_logger_on_first_use*
220
+ Arguments:
221
+
222
+ processors: The processor chain. See :doc:`processors` for details.
223
+
224
+ wrapper_class:
225
+ Class to use for wrapping loggers instead of
226
+ `structlog.BoundLogger`. See `standard-library`, :doc:`twisted`,
227
+ and `custom-wrappers`.
228
+
229
+ context_class:
230
+ Class to be used for internal context keeping. The default is a
231
+ `dict` and since dictionaries are ordered as of Python 3.6, there's
232
+ few reasons to change this option.
233
+
234
+ logger_factory:
235
+ Factory to be called to create a new logger that shall be wrapped.
236
+
237
+ cache_logger_on_first_use:
238
+ `wrap_logger` doesn't return an actual wrapped logger but a proxy
239
+ that assembles one when it's first used. If this option is set to
240
+ `True`, this assembled logger is cached. See `performance`.
241
+
242
+ .. versionadded:: 0.3.0 *cache_logger_on_first_use*
226
243
"""
227
244
_CONFIG .is_configured = True
228
245
@@ -251,7 +268,9 @@ def configure_once(
251
268
It does *not* matter whether it was configured using `configure` or
252
269
`configure_once` before.
253
270
254
- Raises a `RuntimeWarning` if repeated configuration is attempted.
271
+ Raises:
272
+
273
+ RuntimeWarning: if repeated configuration is attempted.
255
274
"""
256
275
if not _CONFIG .is_configured :
257
276
configure (
@@ -290,11 +309,10 @@ class BoundLoggerLazyProxy:
290
309
The only points where a bound logger changes state are ``bind()``,
291
310
``unbind()``, and ``new()`` and that return the actual ``BoundLogger``.
292
311
293
- If and only if configuration says so, that actual bound logger is
294
- cached on first usage.
312
+ If and only if configuration says so, that actual bound logger is cached on
313
+ first usage.
295
314
296
- .. versionchanged:: 0.4.0
297
- Added support for *logger_factory_args*.
315
+ .. versionchanged:: 0.4.0 Added support for *logger_factory_args*.
298
316
"""
299
317
300
318
def __init__ (
0 commit comments