custom-python-logger 2.0.5__tar.gz → 2.0.6__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.5/custom_python_logger.egg-info → custom_python_logger-2.0.6}/PKG-INFO +1 -1
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/custom_python_logger/__init__.py +2 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/custom_python_logger/logger.py +12 -12
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6/custom_python_logger.egg-info}/PKG-INFO +1 -1
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/custom_python_logger.egg-info/SOURCES.txt +0 -1
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/setup.py +1 -1
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/tests/test_usage_example_pytest.py +1 -1
- custom_python_logger-2.0.5/custom_python_logger/usage_example.py +0 -42
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/LICENSE +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/MANIFEST.in +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/README.md +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/custom_python_logger/consts.py +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/custom_python_logger.egg-info/dependency_links.txt +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/custom_python_logger.egg-info/requires.txt +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/custom_python_logger.egg-info/top_level.txt +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/pyproject.toml +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/requirements.txt +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/setup.cfg +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/tests/test_logger.py +0 -0
- {custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/tests/test_logger_pytest.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from custom_python_logger.logger import (
|
|
2
2
|
CustomLoggerAdapter,
|
|
3
|
+
CustomLoggerLevel,
|
|
3
4
|
build_logger,
|
|
4
5
|
get_logger,
|
|
5
6
|
json_pretty_format,
|
|
@@ -8,6 +9,7 @@ from custom_python_logger.logger import (
|
|
|
8
9
|
|
|
9
10
|
__all__ = [
|
|
10
11
|
"CustomLoggerAdapter",
|
|
12
|
+
"CustomLoggerLevel",
|
|
11
13
|
"build_logger",
|
|
12
14
|
"get_logger",
|
|
13
15
|
"json_pretty_format",
|
|
@@ -136,6 +136,17 @@ def configure_logging(
|
|
|
136
136
|
)
|
|
137
137
|
|
|
138
138
|
|
|
139
|
+
def get_logger(name: str, log_level: int | None = None, extra: dict | None = None) -> CustomLoggerAdapter:
|
|
140
|
+
child_logger = logging.getLogger(CHILD_LOGGER)
|
|
141
|
+
new_logger = CustomLoggerAdapter(logging.getLogger(name), extra=extra)
|
|
142
|
+
|
|
143
|
+
if not log_level:
|
|
144
|
+
log_level = child_logger.level
|
|
145
|
+
new_logger.setLevel(log_level)
|
|
146
|
+
|
|
147
|
+
return new_logger
|
|
148
|
+
|
|
149
|
+
|
|
139
150
|
def build_logger(
|
|
140
151
|
project_name: str,
|
|
141
152
|
extra: dict[str, Any] | None = None,
|
|
@@ -175,15 +186,4 @@ def build_logger(
|
|
|
175
186
|
logger = CustomLoggerAdapter(logging.getLogger(CHILD_LOGGER), extra)
|
|
176
187
|
logger.setLevel(log_level)
|
|
177
188
|
|
|
178
|
-
return
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
def get_logger(name: str, log_level: int | None = None, extra: dict | None = None) -> CustomLoggerAdapter:
|
|
182
|
-
child_logger = logging.getLogger(CHILD_LOGGER)
|
|
183
|
-
new_logger = CustomLoggerAdapter(logging.getLogger(name), extra=extra)
|
|
184
|
-
|
|
185
|
-
if not log_level:
|
|
186
|
-
log_level = child_logger.level
|
|
187
|
-
new_logger.setLevel(log_level)
|
|
188
|
-
|
|
189
|
-
return new_logger
|
|
189
|
+
return get_logger(project_name)
|
{custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/custom_python_logger.egg-info/SOURCES.txt
RENAMED
|
@@ -7,7 +7,6 @@ setup.py
|
|
|
7
7
|
custom_python_logger/__init__.py
|
|
8
8
|
custom_python_logger/consts.py
|
|
9
9
|
custom_python_logger/logger.py
|
|
10
|
-
custom_python_logger/usage_example.py
|
|
11
10
|
custom_python_logger.egg-info/PKG-INFO
|
|
12
11
|
custom_python_logger.egg-info/SOURCES.txt
|
|
13
12
|
custom_python_logger.egg-info/dependency_links.txt
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
|
|
3
|
-
from custom_python_logger import build_logger, get_logger
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class LoggerTest:
|
|
7
|
-
def __init__(self) -> None:
|
|
8
|
-
self.logger = get_logger(self.__class__.__name__, extra={"class": self.__class__.__name__})
|
|
9
|
-
print()
|
|
10
|
-
|
|
11
|
-
def main(self) -> None:
|
|
12
|
-
self.logger.debug("Hello World")
|
|
13
|
-
self.logger.info("Hello World")
|
|
14
|
-
self.logger.step("Hello World")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def main() -> None:
|
|
18
|
-
logger = build_logger(
|
|
19
|
-
project_name="Logger Project Test",
|
|
20
|
-
log_level=logging.DEBUG,
|
|
21
|
-
log_file=True,
|
|
22
|
-
# extra={'user': 'test_user'}
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
logger.debug("This is a debug message.")
|
|
26
|
-
logger.info("This is an info message.")
|
|
27
|
-
logger.step("This is a step message.")
|
|
28
|
-
logger.warning("This is a warning message.")
|
|
29
|
-
|
|
30
|
-
try:
|
|
31
|
-
_ = 1 / 0
|
|
32
|
-
except ZeroDivisionError:
|
|
33
|
-
logger.exception("This is an exception message.")
|
|
34
|
-
|
|
35
|
-
logger.critical("This is a critical message.")
|
|
36
|
-
|
|
37
|
-
logger_test = LoggerTest()
|
|
38
|
-
logger_test.main()
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if __name__ == "__main__":
|
|
42
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{custom_python_logger-2.0.5 → custom_python_logger-2.0.6}/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
|