custom-python-logger 4.0.0__tar.gz → 4.0.1__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.
- {custom_python_logger-4.0.0/custom_python_logger.egg-info → custom_python_logger-4.0.1}/PKG-INFO +1 -1
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/custom_python_logger/logger.py +14 -3
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1/custom_python_logger.egg-info}/PKG-INFO +1 -1
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/pyproject.toml +1 -1
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/LICENSE +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/MANIFEST.in +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/README.md +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/custom_python_logger/__init__.py +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/custom_python_logger/consts.py +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/custom_python_logger.egg-info/SOURCES.txt +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/custom_python_logger.egg-info/dependency_links.txt +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/custom_python_logger.egg-info/requires.txt +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/custom_python_logger.egg-info/top_level.txt +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/setup.cfg +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/tests/test_logger.py +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/tests/test_logger_pytest.py +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/tests/test_short_path_filter.py +0 -0
- {custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/tests/test_usage_example_pytest.py +0 -0
|
@@ -10,7 +10,7 @@ from typing import Any
|
|
|
10
10
|
import yaml
|
|
11
11
|
from colorlog import ColoredFormatter
|
|
12
12
|
|
|
13
|
-
from custom_python_logger.consts import LOG_COLORS,
|
|
13
|
+
from custom_python_logger.consts import LOG_COLORS, LOG_FORMAT_FILENAME, CustomLoggerLevel
|
|
14
14
|
|
|
15
15
|
CUSTOM_LOGGER = "custom_logger"
|
|
16
16
|
|
|
@@ -64,6 +64,14 @@ class _ShortPathFilter(logging.Filter):
|
|
|
64
64
|
return True
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
class _StripNamespaceFilter(logging.Filter):
|
|
68
|
+
def filter(self, record: logging.LogRecord) -> bool:
|
|
69
|
+
prefix = CUSTOM_LOGGER + "."
|
|
70
|
+
if record.name.startswith(prefix):
|
|
71
|
+
record.name = record.name[len(prefix) :]
|
|
72
|
+
return True
|
|
73
|
+
|
|
74
|
+
|
|
67
75
|
class CustomLoggerAdapter(logging.LoggerAdapter):
|
|
68
76
|
def exception(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
69
77
|
logging.addLevelName(CustomLoggerLevel.EXCEPTION.value, "EXCEPTION")
|
|
@@ -121,8 +129,11 @@ def add_console_handler(logger: Logger, log_format: str) -> None:
|
|
|
121
129
|
|
|
122
130
|
def get_logger(name: str, log_level: int | None = None, extra: dict | None = None) -> CustomLoggerAdapter:
|
|
123
131
|
custom_logger = logging.getLogger(CUSTOM_LOGGER)
|
|
132
|
+
|
|
124
133
|
full_name = f"{CUSTOM_LOGGER}.{name}"
|
|
125
|
-
|
|
134
|
+
underlying = logging.getLogger(full_name)
|
|
135
|
+
underlying.addFilter(_StripNamespaceFilter())
|
|
136
|
+
new_logger = CustomLoggerAdapter(underlying, extra=extra)
|
|
126
137
|
|
|
127
138
|
if log_level is None:
|
|
128
139
|
log_level = custom_logger.level
|
|
@@ -134,7 +145,7 @@ def get_logger(name: str, log_level: int | None = None, extra: dict | None = Non
|
|
|
134
145
|
def build_logger( # pylint: disable=R0913
|
|
135
146
|
project_name: str,
|
|
136
147
|
extra: dict[str, Any] | None = None,
|
|
137
|
-
log_format: str =
|
|
148
|
+
log_format: str = LOG_FORMAT_FILENAME,
|
|
138
149
|
log_level: int = logging.DEBUG,
|
|
139
150
|
log_file: bool = False,
|
|
140
151
|
log_file_path: str | None = None,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/custom_python_logger.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/custom_python_logger.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{custom_python_logger-4.0.0 → custom_python_logger-4.0.1}/tests/test_usage_example_pytest.py
RENAMED
|
File without changes
|