python-json-logger 3.2.1.dev1__py3-none-any.whl → 4.0.0.dev0__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-json-logger
3
- Version: 3.2.1.dev1
3
+ Version: 4.0.0.dev0
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>
@@ -27,8 +27,7 @@ License-File: NOTICE
27
27
  Requires-Dist: typing_extensions; python_version < "3.10"
28
28
  Provides-Extra: dev
29
29
  Requires-Dist: orjson; implementation_name != "pypy" and extra == "dev"
30
- Requires-Dist: msgspec; (implementation_name != "pypy" and python_version < "3.13") and extra == "dev"
31
- Requires-Dist: msgspec-python313-pre; (implementation_name != "pypy" and python_version == "3.13") and extra == "dev"
30
+ Requires-Dist: msgspec; implementation_name != "pypy" and extra == "dev"
32
31
  Requires-Dist: validate-pyproject[all]; extra == "dev"
33
32
  Requires-Dist: black; extra == "dev"
34
33
  Requires-Dist: pylint; extra == "dev"
@@ -46,9 +45,11 @@ Requires-Dist: mkdocstrings[python]; extra == "dev"
46
45
  Requires-Dist: mkdocs-gen-files; extra == "dev"
47
46
  Requires-Dist: mkdocs-literate-nav; extra == "dev"
48
47
  Requires-Dist: mike; extra == "dev"
48
+ Dynamic: license-file
49
49
 
50
50
  [![PyPi](https://img.shields.io/pypi/v/python-json-logger.svg)](https://pypi.python.org/pypi/python-json-logger/)
51
51
  [![PyPI - Status](https://img.shields.io/pypi/status/python-json-logger)](https://pypi.python.org/pypi/python-json-logger/)
52
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/python-json-logger)](https://pypi.python.org/pypi/python-json-logger/)
52
53
  [![Python Versions](https://img.shields.io/pypi/pyversions/python-json-logger.svg)](https://github.com/nhairs/python-json-logger)
53
54
  [![License](https://img.shields.io/github/license/nhairs/python-json-logger.svg)](https://github.com/nhairs/python-json-logger)
54
55
  ![Build Status](https://github.com/nhairs/python-json-logger/actions/workflows/test-suite.yml/badge.svg)
@@ -1,5 +1,7 @@
1
+ python_json_logger-4.0.0.dev0.dist-info/licenses/LICENSE,sha256=GOqVF546Xg4k62zhbED7--IxM8JQKTOi91-KPhoFW1Q,1329
2
+ python_json_logger-4.0.0.dev0.dist-info/licenses/NOTICE,sha256=uRQnFcGZCwuIBR2AIHVvhKi9w1KkiI_vAyralfxCsk4,209
1
3
  pythonjsonlogger/__init__.py,sha256=2QcveuId10CyXff_BtJ_6kXIarHT5oq66XHHMFiaE8s,419
2
- pythonjsonlogger/core.py,sha256=zrf2vBMPVjPv5ornwWs2TOi68FbWDnuhj_DrcUiuBG0,13328
4
+ pythonjsonlogger/core.py,sha256=j0j8jeC43jw1RGzu-Tvna79QoU5qdMMyU9fq4syNiPM,14967
3
5
  pythonjsonlogger/defaults.py,sha256=-XgxIj8ioq7CsnBBMsQhTRpU-lKbLrpQLJTCaT3iH38,6577
4
6
  pythonjsonlogger/exception.py,sha256=r3DXDk7TThscnMVNPpVRaRSFHTnY-ygea6nn-FgjwsI,804
5
7
  pythonjsonlogger/json.py,sha256=TsKD_1-TDjaeMUg6la_aVzIWd7GBxgAntY6zWzVe7lU,4165
@@ -8,9 +10,7 @@ pythonjsonlogger/msgspec.py,sha256=M5kiIX4RLr1PwvWKx21N8sgk05LCFymBAWM4cRR3VNA,2
8
10
  pythonjsonlogger/orjson.py,sha256=HVhIHo7CrTwj9pZuZzUmj1qsW0coNdVmDKSDycDs-pM,2357
9
11
  pythonjsonlogger/py.typed,sha256=4RLptUHQuSqzK6CDbigff8uvWQjwPPQMxikWPkV4OtA,80
10
12
  pythonjsonlogger/utils.py,sha256=qr04nb61TkVw7cJTXAtLBfyH_NBvyYUlR_mehH76-RM,1126
11
- python_json_logger-3.2.1.dev1.dist-info/LICENSE,sha256=GOqVF546Xg4k62zhbED7--IxM8JQKTOi91-KPhoFW1Q,1329
12
- python_json_logger-3.2.1.dev1.dist-info/METADATA,sha256=0IeIadiU85OUHVlSmaK_IkDVajdlbJsRVHvnSjFmajE,3999
13
- python_json_logger-3.2.1.dev1.dist-info/NOTICE,sha256=uRQnFcGZCwuIBR2AIHVvhKi9w1KkiI_vAyralfxCsk4,209
14
- python_json_logger-3.2.1.dev1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
15
- python_json_logger-3.2.1.dev1.dist-info/top_level.txt,sha256=9G-OsTkbwPgM8t-bXKPmWDBRZv9cbzLIiEDE5EnGk2I,17
16
- python_json_logger-3.2.1.dev1.dist-info/RECORD,,
13
+ python_json_logger-4.0.0.dev0.dist-info/METADATA,sha256=Oa4f3Ss6w6AeqpoJLDBSuPTQX-tTURtrVfCr8rlDHEM,3996
14
+ python_json_logger-4.0.0.dev0.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
15
+ python_json_logger-4.0.0.dev0.dist-info/top_level.txt,sha256=9G-OsTkbwPgM8t-bXKPmWDBRZv9cbzLIiEDE5EnGk2I,17
16
+ python_json_logger-4.0.0.dev0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (79.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
pythonjsonlogger/core.py CHANGED
@@ -134,6 +134,8 @@ class BaseJsonFormatter(logging.Formatter):
134
134
  *New in 3.1*
135
135
 
136
136
  *Changed in 3.2*: `defaults` argument is no longer ignored.
137
+
138
+ *Added in UNRELEASED*: `exc_info_as_array` and `stack_info_as_array` options are added.
137
139
  """
138
140
 
139
141
  _style: Union[logging.PercentStyle, str] # type: ignore[assignment]
@@ -155,6 +157,8 @@ class BaseJsonFormatter(logging.Formatter):
155
157
  reserved_attrs: Optional[Sequence[str]] = None,
156
158
  timestamp: Union[bool, str] = False,
157
159
  defaults: Optional[Dict[str, Any]] = None,
160
+ exc_info_as_array: bool = False,
161
+ stack_info_as_array: bool = False,
158
162
  ) -> None:
159
163
  """
160
164
  Args:
@@ -177,6 +181,8 @@ class BaseJsonFormatter(logging.Formatter):
177
181
  outputting the json log record. If string is passed, timestamp will be added
178
182
  to log record using string as key. If True boolean is passed, timestamp key
179
183
  will be "timestamp". Defaults to False/off.
184
+ exc_info_as_array: break the exc_info into a list of lines based on line breaks.
185
+ stack_info_as_array: break the stack_info into a list of lines based on line breaks.
180
186
 
181
187
  *Changed in 3.1*:
182
188
 
@@ -209,9 +215,18 @@ class BaseJsonFormatter(logging.Formatter):
209
215
  ## JSON Logging specific
210
216
  ## ---------------------------------------------------------------------
211
217
  self.prefix = prefix
212
- self.rename_fields = rename_fields if rename_fields is not None else {}
218
+
219
+ # We recreate the dict in rename_fields and static_fields to support internal/external
220
+ # references which require getting the item to do the conversion.
221
+ # For more details see: https://github.com/nhairs/python-json-logger/pull/45
222
+ self.rename_fields = (
223
+ {key: rename_fields[key] for key in rename_fields} if rename_fields is not None else {}
224
+ )
225
+ self.static_fields = (
226
+ {key: static_fields[key] for key in static_fields} if static_fields is not None else {}
227
+ )
228
+
213
229
  self.rename_fields_keep_missing = rename_fields_keep_missing
214
- self.static_fields = static_fields if static_fields is not None else {}
215
230
  self.reserved_attrs = set(reserved_attrs if reserved_attrs is not None else RESERVED_ATTRS)
216
231
  self.timestamp = timestamp
217
232
 
@@ -219,6 +234,8 @@ class BaseJsonFormatter(logging.Formatter):
219
234
  self._skip_fields = set(self._required_fields)
220
235
  self._skip_fields.update(self.reserved_attrs)
221
236
  self.defaults = defaults if defaults is not None else {}
237
+ self.exc_info_as_array = exc_info_as_array
238
+ self.stack_info_as_array = stack_info_as_array
222
239
  return
223
240
 
224
241
  def format(self, record: logging.LogRecord) -> str:
@@ -368,3 +385,19 @@ class BaseJsonFormatter(logging.Formatter):
368
385
  log_record: incoming data
369
386
  """
370
387
  return log_record
388
+
389
+ def formatException(self, ei) -> Union[str, list[str]]: # type: ignore
390
+ """Format and return the specified exception information.
391
+
392
+ If exc_info_as_array is set to True, This method returns an array of strings.
393
+ """
394
+ exception_info_str = super().formatException(ei)
395
+ return exception_info_str.splitlines() if self.exc_info_as_array else exception_info_str
396
+
397
+ def formatStack(self, stack_info) -> Union[str, list[str]]: # type: ignore
398
+ """Format and return the specified stack information.
399
+
400
+ If stack_info_as_array is set to True, This method returns an array of strings.
401
+ """
402
+ stack_info_str = super().formatStack(stack_info)
403
+ return stack_info_str.splitlines() if self.stack_info_as_array else stack_info_str