python-json-logger 4.0.0rc1__tar.gz → 4.1.0__tar.gz

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.
Files changed (27) hide show
  1. {python_json_logger-4.0.0rc1/src/python_json_logger.egg-info → python_json_logger-4.1.0}/PKG-INFO +4 -9
  2. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/pyproject.toml +5 -10
  3. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0/src/python_json_logger.egg-info}/PKG-INFO +4 -9
  4. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/python_json_logger.egg-info/requires.txt +0 -6
  5. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/core.py +21 -25
  6. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/defaults.py +1 -7
  7. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/json.py +5 -4
  8. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/msgspec.py +3 -2
  9. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/orjson.py +4 -3
  10. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/tests/test_dictconfig.py +3 -2
  11. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/tests/test_formatters.py +5 -7
  12. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/LICENSE +0 -0
  13. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/MANIFEST.in +0 -0
  14. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/NOTICE +0 -0
  15. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/README.md +0 -0
  16. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/setup.cfg +0 -0
  17. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/python_json_logger.egg-info/SOURCES.txt +0 -0
  18. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/python_json_logger.egg-info/dependency_links.txt +0 -0
  19. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/python_json_logger.egg-info/top_level.txt +0 -0
  20. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/__init__.py +0 -0
  21. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/exception.py +0 -0
  22. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/jsonlogger.py +0 -0
  23. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/py.typed +0 -0
  24. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/src/pythonjsonlogger/utils.py +0 -0
  25. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/tests/__init__.py +0 -0
  26. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/tests/test_deprecation.py +0 -0
  27. {python_json_logger-4.0.0rc1 → python_json_logger-4.1.0}/tests/test_missing.py +0 -0
@@ -1,30 +1,26 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-json-logger
3
- Version: 4.0.0rc1
3
+ Version: 4.1.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>
7
- License: BSD-2-Clause License
7
+ License-Expression: BSD-2-Clause
8
8
  Project-URL: Homepage, https://nhairs.github.io/python-json-logger
9
9
  Project-URL: GitHub, https://github.com/nhairs/python-json-logger
10
10
  Classifier: Development Status :: 6 - Mature
11
11
  Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: BSD License
13
12
  Classifier: Operating System :: OS Independent
14
13
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.8
16
- Classifier: Programming Language :: Python :: 3.9
17
14
  Classifier: Programming Language :: Python :: 3.10
18
15
  Classifier: Programming Language :: Python :: 3.11
19
16
  Classifier: Programming Language :: Python :: 3.12
20
17
  Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
21
19
  Classifier: Topic :: System :: Logging
22
20
  Classifier: Typing :: Typed
23
- Requires-Python: >=3.8
21
+ Requires-Python: >=3.10
24
22
  Description-Content-Type: text/markdown
25
23
  License-File: LICENSE
26
- License-File: NOTICE
27
- Requires-Dist: typing_extensions; python_version < "3.10"
28
24
  Provides-Extra: dev
29
25
  Requires-Dist: orjson; implementation_name != "pypy" and extra == "dev"
30
26
  Requires-Dist: msgspec; implementation_name != "pypy" and extra == "dev"
@@ -34,7 +30,6 @@ Requires-Dist: pylint; extra == "dev"
34
30
  Requires-Dist: mypy; extra == "dev"
35
31
  Requires-Dist: pytest; extra == "dev"
36
32
  Requires-Dist: freezegun; extra == "dev"
37
- Requires-Dist: backports.zoneinfo; python_version < "3.9" and extra == "dev"
38
33
  Requires-Dist: tzdata; extra == "dev"
39
34
  Requires-Dist: build; extra == "dev"
40
35
  Requires-Dist: mkdocs; extra == "dev"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python-json-logger"
7
- version = "4.0.0.rc1"
7
+ version = "4.1.0"
8
8
  description = "JSON Log Formatter for the Python Logging Package"
9
9
  authors = [
10
10
  {name = "Zakaria Zajac", email = "zak@madzak.com"},
@@ -15,26 +15,22 @@ maintainers = [
15
15
  ]
16
16
 
17
17
  # Dependency Information
18
- requires-python = ">=3.8"
19
- dependencies = [
20
- "typing_extensions;python_version<'3.10'",
21
- ]
18
+ requires-python = ">=3.10"
22
19
 
23
20
  # Extra information
24
21
  readme = "README.md"
25
- license = {text = "BSD-2-Clause License"}
22
+ license = "BSD-2-Clause"
23
+ license-files = ["LICENSE"]
26
24
  classifiers = [
27
25
  "Development Status :: 6 - Mature",
28
26
  "Intended Audience :: Developers",
29
- "License :: OSI Approved :: BSD License",
30
27
  "Operating System :: OS Independent",
31
28
  "Programming Language :: Python :: 3 :: Only",
32
- "Programming Language :: Python :: 3.8",
33
- "Programming Language :: Python :: 3.9",
34
29
  "Programming Language :: Python :: 3.10",
35
30
  "Programming Language :: Python :: 3.11",
36
31
  "Programming Language :: Python :: 3.12",
37
32
  "Programming Language :: Python :: 3.13",
33
+ "Programming Language :: Python :: 3.14",
38
34
  "Topic :: System :: Logging",
39
35
  "Typing :: Typed",
40
36
  ]
@@ -56,7 +52,6 @@ dev = [
56
52
  ## Test
57
53
  "pytest",
58
54
  "freezegun",
59
- "backports.zoneinfo;python_version<'3.9'",
60
55
  "tzdata",
61
56
  ## Build
62
57
  "build",
@@ -1,30 +1,26 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-json-logger
3
- Version: 4.0.0rc1
3
+ Version: 4.1.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>
7
- License: BSD-2-Clause License
7
+ License-Expression: BSD-2-Clause
8
8
  Project-URL: Homepage, https://nhairs.github.io/python-json-logger
9
9
  Project-URL: GitHub, https://github.com/nhairs/python-json-logger
10
10
  Classifier: Development Status :: 6 - Mature
11
11
  Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: BSD License
13
12
  Classifier: Operating System :: OS Independent
14
13
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.8
16
- Classifier: Programming Language :: Python :: 3.9
17
14
  Classifier: Programming Language :: Python :: 3.10
18
15
  Classifier: Programming Language :: Python :: 3.11
19
16
  Classifier: Programming Language :: Python :: 3.12
20
17
  Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
21
19
  Classifier: Topic :: System :: Logging
22
20
  Classifier: Typing :: Typed
23
- Requires-Python: >=3.8
21
+ Requires-Python: >=3.10
24
22
  Description-Content-Type: text/markdown
25
23
  License-File: LICENSE
26
- License-File: NOTICE
27
- Requires-Dist: typing_extensions; python_version < "3.10"
28
24
  Provides-Extra: dev
29
25
  Requires-Dist: orjson; implementation_name != "pypy" and extra == "dev"
30
26
  Requires-Dist: msgspec; implementation_name != "pypy" and extra == "dev"
@@ -34,7 +30,6 @@ Requires-Dist: pylint; extra == "dev"
34
30
  Requires-Dist: mypy; extra == "dev"
35
31
  Requires-Dist: pytest; extra == "dev"
36
32
  Requires-Dist: freezegun; extra == "dev"
37
- Requires-Dist: backports.zoneinfo; python_version < "3.9" and extra == "dev"
38
33
  Requires-Dist: tzdata; extra == "dev"
39
34
  Requires-Dist: build; extra == "dev"
40
35
  Requires-Dist: mkdocs; extra == "dev"
@@ -1,7 +1,4 @@
1
1
 
2
- [:python_version < "3.10"]
3
- typing_extensions
4
-
5
2
  [dev]
6
3
  validate-pyproject[all]
7
4
  black
@@ -23,6 +20,3 @@ mike
23
20
  [dev:implementation_name != "pypy"]
24
21
  orjson
25
22
  msgspec
26
-
27
- [dev:python_version < "3.9"]
28
- backports.zoneinfo
@@ -10,12 +10,8 @@ from datetime import datetime, timezone
10
10
  import logging
11
11
  import re
12
12
  import sys
13
- from typing import Optional, Union, List, Dict, Container, Any, Sequence
14
-
15
- if sys.version_info >= (3, 10):
16
- from typing import TypeAlias
17
- else:
18
- from typing_extensions import TypeAlias
13
+ from typing import TypeAlias, Any
14
+ from collections.abc import Container, Sequence
19
15
 
20
16
  ## Installed
21
17
 
@@ -24,7 +20,7 @@ else:
24
20
 
25
21
  ### CONSTANTS
26
22
  ### ============================================================================
27
- RESERVED_ATTRS: List[str] = [
23
+ RESERVED_ATTRS: list[str] = [
28
24
  "args",
29
25
  "asctime",
30
26
  "created",
@@ -71,7 +67,7 @@ STYLE_PERCENT_REGEX = re.compile(r"%\((.+?)\)", re.IGNORECASE) # % style
71
67
 
72
68
  ## Type Aliases
73
69
  ## -----------------------------------------------------------------------------
74
- LogData: TypeAlias = Dict[str, Any]
70
+ LogData: TypeAlias = dict[str, Any]
75
71
  """Type alias
76
72
 
77
73
  *Changed in 4.0*: renamed from `LogRecord` to `LogData`
@@ -82,10 +78,10 @@ LogData: TypeAlias = Dict[str, Any]
82
78
  ### ============================================================================
83
79
  def merge_record_extra(
84
80
  record: logging.LogRecord,
85
- target: Dict,
81
+ target: dict[Any, Any],
86
82
  reserved: Container[str],
87
- rename_fields: Optional[Dict[str, str]] = None,
88
- ) -> Dict:
83
+ rename_fields: dict[str, str] | None = None,
84
+ ) -> dict[Any, Any]:
89
85
  """
90
86
  Merges extra attributes from LogRecord object into target dictionary
91
87
 
@@ -121,25 +117,25 @@ class BaseJsonFormatter(logging.Formatter):
121
117
  *Added in 3.3*: `exc_info_as_array` and `stack_info_as_array` options are added.
122
118
  """
123
119
 
124
- _style: Union[logging.PercentStyle, str] # type: ignore[assignment]
120
+ _style: logging.PercentStyle | str # type: ignore[assignment]
125
121
 
126
122
  ## Parent Methods
127
123
  ## -------------------------------------------------------------------------
128
124
  # pylint: disable=too-many-arguments,super-init-not-called
129
125
  def __init__(
130
126
  self,
131
- fmt: Optional[Union[str, Sequence[str]]] = None,
132
- datefmt: Optional[str] = None,
127
+ fmt: str | Sequence[str] | None = None,
128
+ datefmt: str | None = None,
133
129
  style: str = "%",
134
130
  validate: bool = True,
135
131
  *,
136
132
  prefix: str = "",
137
- rename_fields: Optional[Dict[str, str]] = None,
133
+ rename_fields: dict[str, str] | None = None,
138
134
  rename_fields_keep_missing: bool = False,
139
- static_fields: Optional[Dict[str, Any]] = None,
140
- reserved_attrs: Optional[Sequence[str]] = None,
141
- timestamp: Union[bool, str] = False,
142
- defaults: Optional[Dict[str, Any]] = None,
135
+ static_fields: dict[str, Any] | None = None,
136
+ reserved_attrs: Sequence[str] | None = None,
137
+ timestamp: bool | str = False,
138
+ defaults: dict[str, Any] | None = None,
143
139
  exc_info_as_array: bool = False,
144
140
  stack_info_as_array: bool = False,
145
141
  ) -> None:
@@ -243,7 +239,7 @@ class BaseJsonFormatter(logging.Formatter):
243
239
  Args:
244
240
  record: the record to format
245
241
  """
246
- message_dict: Dict[str, Any] = {}
242
+ message_dict: dict[str, Any] = {}
247
243
  # TODO: logging.LogRecord.msg and logging.LogRecord.message in typeshed
248
244
  # are always type of str. We shouldn't need to override that.
249
245
  if isinstance(record.msg, dict):
@@ -276,7 +272,7 @@ class BaseJsonFormatter(logging.Formatter):
276
272
 
277
273
  ## JSON Formatter Specific Methods
278
274
  ## -------------------------------------------------------------------------
279
- def parse(self) -> List[str]:
275
+ def parse(self) -> list[str]:
280
276
  """Parses format string looking for substitutions
281
277
 
282
278
  This method is responsible for returning a list of fields (as strings)
@@ -327,9 +323,9 @@ class BaseJsonFormatter(logging.Formatter):
327
323
 
328
324
  def add_fields(
329
325
  self,
330
- log_data: Dict[str, Any],
326
+ log_data: dict[str, Any],
331
327
  record: logging.LogRecord,
332
- message_dict: Dict[str, Any],
328
+ message_dict: dict[str, Any],
333
329
  ) -> None:
334
330
  """Extract fields from a LogRecord for logging
335
331
 
@@ -402,7 +398,7 @@ class BaseJsonFormatter(logging.Formatter):
402
398
  """
403
399
  return log_data
404
400
 
405
- def formatException(self, ei) -> Union[str, list[str]]: # type: ignore
401
+ def formatException(self, ei) -> str | list[str]: # type: ignore[override]
406
402
  """Format and return the specified exception information.
407
403
 
408
404
  If exc_info_as_array is set to True, This method returns an array of strings.
@@ -410,7 +406,7 @@ class BaseJsonFormatter(logging.Formatter):
410
406
  exception_info_str = super().formatException(ei)
411
407
  return exception_info_str.splitlines() if self.exc_info_as_array else exception_info_str
412
408
 
413
- def formatStack(self, stack_info) -> Union[str, list[str]]: # type: ignore
409
+ def formatStack(self, stack_info) -> str | list[str]: # type: ignore[override]
414
410
  """Format and return the specified stack information.
415
411
 
416
412
  If stack_info_as_array is set to True, This method returns an array of strings.
@@ -16,17 +16,11 @@ import base64
16
16
  import dataclasses
17
17
  import datetime
18
18
  import enum
19
- import sys
20
19
  from types import TracebackType
21
- from typing import Any
20
+ from typing import Any, TypeGuard
22
21
  import traceback
23
22
  import uuid
24
23
 
25
- if sys.version_info >= (3, 10):
26
- from typing import TypeGuard
27
- else:
28
- from typing_extensions import TypeGuard
29
-
30
24
  ## Installed
31
25
 
32
26
  ## Application
@@ -12,7 +12,8 @@ from __future__ import annotations
12
12
  ## Standard Library
13
13
  import datetime
14
14
  import json
15
- from typing import Any, Callable, Optional, Union
15
+ from typing import Any
16
+ from collections.abc import Callable
16
17
  import warnings
17
18
 
18
19
  ## Application
@@ -67,10 +68,10 @@ class JsonFormatter(core.BaseJsonFormatter):
67
68
  def __init__(
68
69
  self,
69
70
  *args,
70
- json_default: Optional[Callable] = None,
71
- json_encoder: Optional[Callable] = None,
71
+ json_default: Callable | None = None,
72
+ json_encoder: Callable | None = None,
72
73
  json_serializer: Callable = json.dumps,
73
- json_indent: Optional[Union[int, str]] = None,
74
+ json_indent: int | str | None = None,
74
75
  json_ensure_ascii: bool = True,
75
76
  **kwargs,
76
77
  ) -> None:
@@ -6,7 +6,8 @@
6
6
  from __future__ import annotations
7
7
 
8
8
  ## Standard Library
9
- from typing import Any, Optional, Callable
9
+ from typing import Any
10
+ from collections.abc import Callable
10
11
 
11
12
  ## Installed
12
13
 
@@ -43,7 +44,7 @@ class MsgspecFormatter(core.BaseJsonFormatter):
43
44
  def __init__(
44
45
  self,
45
46
  *args,
46
- json_default: Optional[Callable] = msgspec_default,
47
+ json_default: Callable | None = msgspec_default,
47
48
  **kwargs,
48
49
  ) -> None:
49
50
  """
@@ -6,7 +6,8 @@
6
6
  from __future__ import annotations
7
7
 
8
8
  ## Standard Library
9
- from typing import Any, Optional, Callable
9
+ from typing import Any
10
+ from collections.abc import Callable
10
11
 
11
12
  ## Installed
12
13
 
@@ -15,7 +16,7 @@ from . import core
15
16
  from . import defaults as d
16
17
  from .utils import package_is_available
17
18
 
18
- # We import msgspec after checking it is available
19
+ # We import orjson after checking it is available
19
20
  package_is_available("orjson", throw_error=True)
20
21
  import orjson # pylint: disable=wrong-import-position,wrong-import-order
21
22
 
@@ -45,7 +46,7 @@ class OrjsonFormatter(core.BaseJsonFormatter):
45
46
  def __init__(
46
47
  self,
47
48
  *args,
48
- json_default: Optional[Callable] = orjson_default,
49
+ json_default: Callable | None = orjson_default,
49
50
  json_indent: bool = False,
50
51
  **kwargs,
51
52
  ) -> None:
@@ -9,7 +9,8 @@ import io
9
9
  import json
10
10
  import logging
11
11
  import logging.config
12
- from typing import Any, Generator
12
+ from typing import Any
13
+ from collections.abc import Generator
13
14
 
14
15
  ## Installed
15
16
  import pytest
@@ -64,7 +65,7 @@ class LoggingEnvironment:
64
65
 
65
66
 
66
67
  @pytest.fixture
67
- def env() -> Generator[LoggingEnvironment, None, None]:
68
+ def env() -> Generator[LoggingEnvironment]:
68
69
  global _LOGGER_COUNT # pylint: disable=global-statement
69
70
  _LOGGER_COUNT += 1
70
71
  logging.config.dictConfig(LOGGING_CONFIG)
@@ -13,13 +13,10 @@ import logging
13
13
  import sys
14
14
  import traceback
15
15
  from types import TracebackType
16
- from typing import Any, Generator
16
+ from typing import Any
17
+ from collections.abc import Generator
17
18
  import uuid
18
-
19
- if sys.version_info >= (3, 9):
20
- import zoneinfo
21
- else:
22
- from backports import zoneinfo
19
+ import zoneinfo
23
20
 
24
21
  ## Installed
25
22
  import freezegun
@@ -63,7 +60,7 @@ class LoggingEnvironment:
63
60
 
64
61
 
65
62
  @pytest.fixture
66
- def env() -> Generator[LoggingEnvironment, None, None]:
63
+ def env() -> Generator[LoggingEnvironment]:
67
64
  global _LOGGER_COUNT # pylint: disable=global-statement
68
65
  _LOGGER_COUNT += 1
69
66
  logger = logging.getLogger(f"pythonjsonlogger.tests.{_LOGGER_COUNT}")
@@ -558,6 +555,7 @@ def test_default_encoder_with_timestamp(env: LoggingEnvironment, class_: type[Ba
558
555
  (False, bool, False),
559
556
  (None, type(None), None),
560
557
  (b"some-bytes", str, "c29tZS1ieXRlcw=="),
558
+ (b"fancy-bytes-\xf0\xf1", str, "ZmFuY3ktYnl0ZXMt8PE="),
561
559
  (datetime.time(16, 45, 30, 100), str, "16:45:30.000100"),
562
560
  (datetime.date(2024, 5, 5), str, "2024-05-05"),
563
561
  (datetime.datetime(2024, 5, 5, 16, 45, 30, 100), str, "2024-05-05T16:45:30.000100"),