custom-python-logger 2.0.6__tar.gz → 2.0.7__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-2.0.6/custom_python_logger.egg-info → custom_python_logger-2.0.7}/PKG-INFO +1 -1
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger/consts.py +7 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger/logger.py +21 -5
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7/custom_python_logger.egg-info}/PKG-INFO +1 -1
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/setup.py +1 -1
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/LICENSE +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/MANIFEST.in +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/README.md +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger/__init__.py +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger.egg-info/SOURCES.txt +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger.egg-info/dependency_links.txt +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger.egg-info/requires.txt +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger.egg-info/top_level.txt +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/pyproject.toml +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/requirements.txt +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/setup.cfg +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/tests/test_logger.py +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/tests/test_logger_pytest.py +0 -0
- {custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/tests/test_usage_example_pytest.py +0 -0
|
@@ -8,9 +8,16 @@ LOG_COLORS = {
|
|
|
8
8
|
"ERROR": "red,bold",
|
|
9
9
|
"EXCEPTION": "light_red,bold",
|
|
10
10
|
"CRITICAL": "red,bg_white",
|
|
11
|
+
"SUCCESS": "bold_green",
|
|
12
|
+
"FATAL": "red,bg_white",
|
|
13
|
+
"ALERT": "bold_yellow",
|
|
14
|
+
"TRACE": "bold_cyan",
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
class CustomLoggerLevel(Enum):
|
|
15
19
|
EXCEPTION = 45
|
|
16
20
|
STEP = 25
|
|
21
|
+
SUCCESS = 26
|
|
22
|
+
ALERT = 35
|
|
23
|
+
TRACE = 15
|
|
@@ -12,7 +12,7 @@ from colorlog import ColoredFormatter
|
|
|
12
12
|
|
|
13
13
|
from custom_python_logger.consts import LOG_COLORS, CustomLoggerLevel
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
CUSTOM_LOGGER = "custom_logger"
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def json_pretty_format(data: Any, indent: int = 4, sort_keys: bool = True, default: Callable = None) -> str:
|
|
@@ -60,6 +60,21 @@ class CustomLoggerAdapter(logging.LoggerAdapter):
|
|
|
60
60
|
kwargs.setdefault("stacklevel", 2)
|
|
61
61
|
self.log(CustomLoggerLevel.STEP.value, msg, *args, exc_info=False, **kwargs)
|
|
62
62
|
|
|
63
|
+
def success(self, msg: str, *args, **kwargs) -> None:
|
|
64
|
+
logging.addLevelName(CustomLoggerLevel.SUCCESS.value, "SUCCESS")
|
|
65
|
+
kwargs.setdefault("stacklevel", 2)
|
|
66
|
+
self.log(CustomLoggerLevel.SUCCESS.value, msg, *args, **kwargs)
|
|
67
|
+
|
|
68
|
+
def alert(self, msg: str, *args, **kwargs) -> None:
|
|
69
|
+
logging.addLevelName(CustomLoggerLevel.ALERT.value, "ALERT")
|
|
70
|
+
kwargs.setdefault("stacklevel", 2)
|
|
71
|
+
self.log(CustomLoggerLevel.ALERT.value, msg, *args, **kwargs)
|
|
72
|
+
|
|
73
|
+
def trace(self, msg: str, *args, **kwargs) -> None:
|
|
74
|
+
logging.addLevelName(CustomLoggerLevel.TRACE.value, "TRACE")
|
|
75
|
+
kwargs.setdefault("stacklevel", 2)
|
|
76
|
+
self.log(CustomLoggerLevel.TRACE.value, msg, *args, **kwargs)
|
|
77
|
+
|
|
63
78
|
|
|
64
79
|
def clear_existing_handlers(logger: Logger) -> None:
|
|
65
80
|
for handler in logger.handlers[:]:
|
|
@@ -137,11 +152,12 @@ def configure_logging(
|
|
|
137
152
|
|
|
138
153
|
|
|
139
154
|
def get_logger(name: str, log_level: int | None = None, extra: dict | None = None) -> CustomLoggerAdapter:
|
|
140
|
-
|
|
141
|
-
|
|
155
|
+
custom_logger = logging.getLogger(CUSTOM_LOGGER)
|
|
156
|
+
full_name = f"{CUSTOM_LOGGER}.{name}"
|
|
157
|
+
new_logger = CustomLoggerAdapter(logging.getLogger(full_name), extra=extra)
|
|
142
158
|
|
|
143
159
|
if not log_level:
|
|
144
|
-
log_level =
|
|
160
|
+
log_level = custom_logger.level
|
|
145
161
|
new_logger.setLevel(log_level)
|
|
146
162
|
|
|
147
163
|
return new_logger
|
|
@@ -183,7 +199,7 @@ def build_logger(
|
|
|
183
199
|
console_output=console_output,
|
|
184
200
|
utc=utc,
|
|
185
201
|
)
|
|
186
|
-
logger = CustomLoggerAdapter(logging.getLogger(
|
|
202
|
+
logger = CustomLoggerAdapter(logging.getLogger(CUSTOM_LOGGER), extra)
|
|
187
203
|
logger.setLevel(log_level)
|
|
188
204
|
|
|
189
205
|
return get_logger(project_name)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/custom_python_logger.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/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
|
|
File without changes
|
{custom_python_logger-2.0.6 → custom_python_logger-2.0.7}/tests/test_usage_example_pytest.py
RENAMED
|
File without changes
|