python-json-logger 4.1.0__py3-none-any.whl → 4.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_json_logger-4.1.0.dist-info → python_json_logger-4.2.0.dist-info}/METADATA +1 -20
- {python_json_logger-4.1.0.dist-info → python_json_logger-4.2.0.dist-info}/RECORD +6 -6
- {python_json_logger-4.1.0.dist-info → python_json_logger-4.2.0.dist-info}/WHEEL +1 -1
- pythonjsonlogger/core.py +26 -17
- {python_json_logger-4.1.0.dist-info → python_json_logger-4.2.0.dist-info}/licenses/LICENSE +0 -0
- {python_json_logger-4.1.0.dist-info → python_json_logger-4.2.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-json-logger
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.2.0
|
|
4
4
|
Summary: JSON Log Formatter for the Python Logging Package
|
|
5
5
|
Author-email: Zakaria Zajac <zak@madzak.com>, Nicholas Hairs <info+python-json-logger@nicholashairs.com>
|
|
6
6
|
Maintainer-email: Nicholas Hairs <info+python-json-logger@nicholashairs.com>
|
|
@@ -21,25 +21,6 @@ Classifier: Typing :: Typed
|
|
|
21
21
|
Requires-Python: >=3.10
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
License-File: LICENSE
|
|
24
|
-
Provides-Extra: dev
|
|
25
|
-
Requires-Dist: orjson; implementation_name != "pypy" and extra == "dev"
|
|
26
|
-
Requires-Dist: msgspec; implementation_name != "pypy" and extra == "dev"
|
|
27
|
-
Requires-Dist: validate-pyproject[all]; extra == "dev"
|
|
28
|
-
Requires-Dist: black; extra == "dev"
|
|
29
|
-
Requires-Dist: pylint; extra == "dev"
|
|
30
|
-
Requires-Dist: mypy; extra == "dev"
|
|
31
|
-
Requires-Dist: pytest; extra == "dev"
|
|
32
|
-
Requires-Dist: freezegun; extra == "dev"
|
|
33
|
-
Requires-Dist: tzdata; extra == "dev"
|
|
34
|
-
Requires-Dist: build; extra == "dev"
|
|
35
|
-
Requires-Dist: mkdocs; extra == "dev"
|
|
36
|
-
Requires-Dist: mkdocs-material>=8.5; extra == "dev"
|
|
37
|
-
Requires-Dist: mkdocs-awesome-pages-plugin; extra == "dev"
|
|
38
|
-
Requires-Dist: mdx_truly_sane_lists; extra == "dev"
|
|
39
|
-
Requires-Dist: mkdocstrings[python]; extra == "dev"
|
|
40
|
-
Requires-Dist: mkdocs-gen-files; extra == "dev"
|
|
41
|
-
Requires-Dist: mkdocs-literate-nav; extra == "dev"
|
|
42
|
-
Requires-Dist: mike; extra == "dev"
|
|
43
24
|
Dynamic: license-file
|
|
44
25
|
|
|
45
26
|
[](https://pypi.python.org/pypi/python-json-logger/)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
python_json_logger-4.
|
|
1
|
+
python_json_logger-4.2.0.dist-info/licenses/LICENSE,sha256=GOqVF546Xg4k62zhbED7--IxM8JQKTOi91-KPhoFW1Q,1329
|
|
2
2
|
pythonjsonlogger/__init__.py,sha256=2QcveuId10CyXff_BtJ_6kXIarHT5oq66XHHMFiaE8s,419
|
|
3
|
-
pythonjsonlogger/core.py,sha256=
|
|
3
|
+
pythonjsonlogger/core.py,sha256=L41AmWK0t5n-QHazXeOlggNX7uzri750i7SFSpeXZ5Q,16268
|
|
4
4
|
pythonjsonlogger/defaults.py,sha256=muj4QzHgUMJH0UwRvgroHKSRfQgHcF9E-EJXhVzAi98,6461
|
|
5
5
|
pythonjsonlogger/exception.py,sha256=r3DXDk7TThscnMVNPpVRaRSFHTnY-ygea6nn-FgjwsI,804
|
|
6
6
|
pythonjsonlogger/json.py,sha256=6aJSqd2BeysAHkQkxb7dPgFpqsFRf4rvWYgaWF2MEC0,4064
|
|
@@ -9,7 +9,7 @@ pythonjsonlogger/msgspec.py,sha256=tdFes9rLrdns9I_C5ascK9a265iNc4UccLPzc8JbFDI,2
|
|
|
9
9
|
pythonjsonlogger/orjson.py,sha256=XWM-jyl6g_40Em8kt188EOspD872xHvYy8aS_CLlssw,2354
|
|
10
10
|
pythonjsonlogger/py.typed,sha256=4RLptUHQuSqzK6CDbigff8uvWQjwPPQMxikWPkV4OtA,80
|
|
11
11
|
pythonjsonlogger/utils.py,sha256=qr04nb61TkVw7cJTXAtLBfyH_NBvyYUlR_mehH76-RM,1126
|
|
12
|
-
python_json_logger-4.
|
|
13
|
-
python_json_logger-4.
|
|
14
|
-
python_json_logger-4.
|
|
15
|
-
python_json_logger-4.
|
|
12
|
+
python_json_logger-4.2.0.dist-info/METADATA,sha256=kgcfdHSWOBb_eR3Xg4Or8GzyuDw9HbClYz9cTx4y5GU,2866
|
|
13
|
+
python_json_logger-4.2.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
14
|
+
python_json_logger-4.2.0.dist-info/top_level.txt,sha256=9G-OsTkbwPgM8t-bXKPmWDBRZv9cbzLIiEDE5EnGk2I,17
|
|
15
|
+
python_json_logger-4.2.0.dist-info/RECORD,,
|
pythonjsonlogger/core.py
CHANGED
|
@@ -61,7 +61,9 @@ if sys.version_info >= (3, 12):
|
|
|
61
61
|
RESERVED_ATTRS.sort()
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
STYLE_STRING_TEMPLATE_REGEX = re.compile(
|
|
64
|
+
STYLE_STRING_TEMPLATE_REGEX = re.compile(
|
|
65
|
+
r"\$(?:\$|\{(?P<braced>.+?)\}|(?P<named>[_a-z][_a-z0-9]*))", re.IGNORECASE
|
|
66
|
+
) # $ style
|
|
65
67
|
STYLE_STRING_FORMAT_REGEX = re.compile(r"\{(.+?)\}", re.IGNORECASE) # { style
|
|
66
68
|
STYLE_PERCENT_REGEX = re.compile(r"%\((.+?)\)", re.IGNORECASE) # % style
|
|
67
69
|
|
|
@@ -111,10 +113,6 @@ class BaseJsonFormatter(logging.Formatter):
|
|
|
111
113
|
Must not be used directly.
|
|
112
114
|
|
|
113
115
|
*New in 3.1*
|
|
114
|
-
|
|
115
|
-
*Changed in 3.2*: `defaults` argument is no longer ignored.
|
|
116
|
-
|
|
117
|
-
*Added in 3.3*: `exc_info_as_array` and `stack_info_as_array` options are added.
|
|
118
116
|
"""
|
|
119
117
|
|
|
120
118
|
_style: logging.PercentStyle | str # type: ignore[assignment]
|
|
@@ -172,16 +170,19 @@ class BaseJsonFormatter(logging.Formatter):
|
|
|
172
170
|
missing fields. The original behaviour, missing fields have a value of `None`, is still
|
|
173
171
|
available by setting `rename_fields_keep_missing` to `True`.
|
|
174
172
|
|
|
173
|
+
*Changed in 3.2*: `defaults` argument is no longer ignored.
|
|
174
|
+
|
|
175
|
+
*Added in 3.3*: `exc_info_as_array` and `stack_info_as_array` options are added.
|
|
176
|
+
|
|
175
177
|
*Added in 4.0*:
|
|
176
178
|
|
|
177
|
-
- `fmt` now supports comma
|
|
179
|
+
- `fmt` now supports comma separated lists (`style=","`). Note that this style is specific
|
|
178
180
|
to `python-json-logger` and thus care should be taken to not to pass this format to other
|
|
179
181
|
logging Formatter implementations.
|
|
180
182
|
- `fmt` now supports sequences of strings (e.g. lists and tuples) of field names.
|
|
181
183
|
"""
|
|
182
184
|
## logging.Formatter compatibility
|
|
183
185
|
## ---------------------------------------------------------------------
|
|
184
|
-
# Note: validate added in python 3.8, defaults added in 3.10
|
|
185
186
|
if fmt is None or isinstance(fmt, str):
|
|
186
187
|
if style in logging._STYLES:
|
|
187
188
|
_style = logging._STYLES[style][0](fmt) # type: ignore[operator]
|
|
@@ -236,14 +237,20 @@ class BaseJsonFormatter(logging.Formatter):
|
|
|
236
237
|
def format(self, record: logging.LogRecord) -> str:
|
|
237
238
|
"""Formats a log record and serializes to json
|
|
238
239
|
|
|
240
|
+
When `record.msg` is a `dict`, adding `exc_info` and `stack_info` does not
|
|
241
|
+
modify the caller's dict.
|
|
242
|
+
|
|
239
243
|
Args:
|
|
240
244
|
record: the record to format
|
|
245
|
+
|
|
246
|
+
*Changed in 4.2.0*: a `dict` `record.msg` is copied instead of modified
|
|
247
|
+
in place.
|
|
241
248
|
"""
|
|
242
249
|
message_dict: dict[str, Any] = {}
|
|
243
250
|
# TODO: logging.LogRecord.msg and logging.LogRecord.message in typeshed
|
|
244
251
|
# are always type of str. We shouldn't need to override that.
|
|
245
252
|
if isinstance(record.msg, dict):
|
|
246
|
-
message_dict = record.msg
|
|
253
|
+
message_dict = record.msg.copy()
|
|
247
254
|
record.message = ""
|
|
248
255
|
else:
|
|
249
256
|
record.message = record.getMessage()
|
|
@@ -296,20 +303,22 @@ class BaseJsonFormatter(logging.Formatter):
|
|
|
296
303
|
raise ValueError(f"Style {self._style!r} is not supported")
|
|
297
304
|
|
|
298
305
|
if isinstance(self._style, logging.StringTemplateStyle):
|
|
299
|
-
|
|
306
|
+
# String templates support both ${name} and $name, and $$ is an escaped literal
|
|
307
|
+
return [
|
|
308
|
+
match.group("braced") or match.group("named")
|
|
309
|
+
for match in STYLE_STRING_TEMPLATE_REGEX.finditer(self._fmt)
|
|
310
|
+
if match.group("braced") or match.group("named")
|
|
311
|
+
]
|
|
300
312
|
|
|
301
|
-
|
|
302
|
-
|
|
313
|
+
if isinstance(self._style, logging.StrFormatStyle):
|
|
314
|
+
return STYLE_STRING_FORMAT_REGEX.findall(self._fmt)
|
|
303
315
|
|
|
304
|
-
|
|
316
|
+
if isinstance(self._style, logging.PercentStyle):
|
|
305
317
|
# PercentStyle is parent class of StringTemplateStyle and StrFormatStyle
|
|
306
318
|
# so it must be checked last.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
else:
|
|
310
|
-
raise ValueError(f"Style {self._style!r} is not supported")
|
|
319
|
+
return STYLE_PERCENT_REGEX.findall(self._fmt)
|
|
311
320
|
|
|
312
|
-
|
|
321
|
+
raise ValueError(f"Style {self._style!r} is not supported")
|
|
313
322
|
|
|
314
323
|
def serialize_log_record(self, log_data: LogData) -> str:
|
|
315
324
|
"""Returns the final representation of the data to be logged
|
|
File without changes
|
|
File without changes
|