python-json-logger 3.3.0__tar.gz → 4.0.0.dev0__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.
- {python_json_logger-3.3.0/src/python_json_logger.egg-info → python_json_logger-4.0.0.dev0}/PKG-INFO +3 -2
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/pyproject.toml +1 -1
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0/src/python_json_logger.egg-info}/PKG-INFO +3 -2
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/python_json_logger.egg-info/SOURCES.txt +1 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/core.py +11 -2
- python_json_logger-4.0.0.dev0/tests/test_dictconfig.py +80 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/LICENSE +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/MANIFEST.in +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/NOTICE +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/README.md +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/setup.cfg +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/python_json_logger.egg-info/dependency_links.txt +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/python_json_logger.egg-info/requires.txt +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/python_json_logger.egg-info/top_level.txt +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/__init__.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/defaults.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/exception.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/json.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/jsonlogger.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/msgspec.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/orjson.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/py.typed +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/utils.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/tests/__init__.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/tests/test_deprecation.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/tests/test_formatters.py +0 -0
- {python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/tests/test_missing.py +0 -0
{python_json_logger-3.3.0/src/python_json_logger.egg-info → python_json_logger-4.0.0.dev0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-json-logger
|
|
3
|
-
Version:
|
|
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>
|
|
@@ -45,6 +45,7 @@ Requires-Dist: mkdocstrings[python]; extra == "dev"
|
|
|
45
45
|
Requires-Dist: mkdocs-gen-files; extra == "dev"
|
|
46
46
|
Requires-Dist: mkdocs-literate-nav; extra == "dev"
|
|
47
47
|
Requires-Dist: mike; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
48
49
|
|
|
49
50
|
[](https://pypi.python.org/pypi/python-json-logger/)
|
|
50
51
|
[](https://pypi.python.org/pypi/python-json-logger/)
|
{python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0/src/python_json_logger.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-json-logger
|
|
3
|
-
Version:
|
|
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>
|
|
@@ -45,6 +45,7 @@ Requires-Dist: mkdocstrings[python]; extra == "dev"
|
|
|
45
45
|
Requires-Dist: mkdocs-gen-files; extra == "dev"
|
|
46
46
|
Requires-Dist: mkdocs-literate-nav; extra == "dev"
|
|
47
47
|
Requires-Dist: mike; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
48
49
|
|
|
49
50
|
[](https://pypi.python.org/pypi/python-json-logger/)
|
|
50
51
|
[](https://pypi.python.org/pypi/python-json-logger/)
|
|
@@ -215,9 +215,18 @@ class BaseJsonFormatter(logging.Formatter):
|
|
|
215
215
|
## JSON Logging specific
|
|
216
216
|
## ---------------------------------------------------------------------
|
|
217
217
|
self.prefix = prefix
|
|
218
|
-
|
|
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
|
+
|
|
219
229
|
self.rename_fields_keep_missing = rename_fields_keep_missing
|
|
220
|
-
self.static_fields = static_fields if static_fields is not None else {}
|
|
221
230
|
self.reserved_attrs = set(reserved_attrs if reserved_attrs is not None else RESERVED_ATTRS)
|
|
222
231
|
self.timestamp = timestamp
|
|
223
232
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
### IMPORTS
|
|
2
|
+
### ============================================================================
|
|
3
|
+
## Future
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
## Standard Library
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
import io
|
|
9
|
+
import json
|
|
10
|
+
import logging
|
|
11
|
+
import logging.config
|
|
12
|
+
from typing import Any, Generator
|
|
13
|
+
|
|
14
|
+
## Installed
|
|
15
|
+
import pytest
|
|
16
|
+
|
|
17
|
+
### SETUP
|
|
18
|
+
### ============================================================================
|
|
19
|
+
_LOGGER_COUNT = 0
|
|
20
|
+
EXT_VAL = 999
|
|
21
|
+
|
|
22
|
+
LOGGING_CONFIG = {
|
|
23
|
+
"version": 1,
|
|
24
|
+
"disable_existing_loggers": False,
|
|
25
|
+
"formatters": {
|
|
26
|
+
"default": {
|
|
27
|
+
"()": "pythonjsonlogger.json.JsonFormatter",
|
|
28
|
+
"static_fields": {"ext-val": "ext://tests.test_dictconfig.EXT_VAL"},
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"handlers": {
|
|
32
|
+
"default": {
|
|
33
|
+
"level": "DEBUG",
|
|
34
|
+
"formatter": "default",
|
|
35
|
+
"class": "logging.StreamHandler",
|
|
36
|
+
"stream": "ext://sys.stdout", # Default is stderr
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
"loggers": {
|
|
40
|
+
"": {"handlers": ["default"], "level": "WARNING", "propagate": False}, # root logger
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class LoggingEnvironment:
|
|
47
|
+
logger: logging.Logger
|
|
48
|
+
buffer: io.StringIO
|
|
49
|
+
|
|
50
|
+
def load_json(self) -> Any:
|
|
51
|
+
return json.loads(self.buffer.getvalue())
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@pytest.fixture
|
|
55
|
+
def env() -> Generator[LoggingEnvironment, None, None]:
|
|
56
|
+
global _LOGGER_COUNT # pylint: disable=global-statement
|
|
57
|
+
_LOGGER_COUNT += 1
|
|
58
|
+
logging.config.dictConfig(LOGGING_CONFIG)
|
|
59
|
+
default_formatter = logging.root.handlers[0].formatter
|
|
60
|
+
logger = logging.getLogger(f"pythonjsonlogger.tests.{_LOGGER_COUNT}")
|
|
61
|
+
logger.setLevel(logging.DEBUG)
|
|
62
|
+
buffer = io.StringIO()
|
|
63
|
+
handler = logging.StreamHandler(buffer)
|
|
64
|
+
handler.setFormatter(default_formatter)
|
|
65
|
+
logger.addHandler(handler)
|
|
66
|
+
yield LoggingEnvironment(logger=logger, buffer=buffer)
|
|
67
|
+
logger.removeHandler(handler)
|
|
68
|
+
logger.setLevel(logging.NOTSET)
|
|
69
|
+
buffer.close()
|
|
70
|
+
return
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### TESTS
|
|
74
|
+
### ============================================================================
|
|
75
|
+
def test_external_reference_support(env: LoggingEnvironment):
|
|
76
|
+
env.logger.info("hello")
|
|
77
|
+
log_json = env.load_json()
|
|
78
|
+
|
|
79
|
+
assert log_json["ext-val"] == EXT_VAL
|
|
80
|
+
return
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/exception.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_json_logger-3.3.0 → python_json_logger-4.0.0.dev0}/src/pythonjsonlogger/jsonlogger.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|