custom-python-logger 1.0.3__tar.gz → 1.0.4__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-1.0.3/custom_python_logger.egg-info → custom_python_logger-1.0.4}/PKG-INFO +1 -1
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/custom_python_logger/__init__.py +1 -1
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/custom_python_logger/logger.py +23 -13
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4/custom_python_logger.egg-info}/PKG-INFO +1 -1
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/setup.py +1 -1
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/LICENSE +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/MANIFEST.in +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/README.md +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/custom_python_logger/usage_example.py +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/custom_python_logger.egg-info/SOURCES.txt +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/custom_python_logger.egg-info/dependency_links.txt +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/custom_python_logger.egg-info/requires.txt +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/custom_python_logger.egg-info/top_level.txt +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/pyproject.toml +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/requirements.txt +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/setup.cfg +0 -0
- {custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/tests/test_logger.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# logger.py
|
|
2
|
-
|
|
2
|
+
import json
|
|
3
3
|
import logging
|
|
4
4
|
import os
|
|
5
5
|
import time
|
|
@@ -14,6 +14,7 @@ def get_root_project_path() -> Path:
|
|
|
14
14
|
return Path(__file__).parents[5]
|
|
15
15
|
return Path(__file__).parent
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
def print_before_logger(project_name: str) -> None:
|
|
18
19
|
main_string = f'Start "{project_name}" Process'
|
|
19
20
|
|
|
@@ -39,11 +40,11 @@ class CustomLoggerAdapter(logging.LoggerAdapter):
|
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
def configure_logging(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
log_format: str,
|
|
44
|
+
utc: bool,
|
|
45
|
+
log_level: int = logging.INFO,
|
|
46
|
+
log_file: Optional[str] = None,
|
|
47
|
+
console_output: bool = True,
|
|
47
48
|
) -> None:
|
|
48
49
|
"""
|
|
49
50
|
Configure global logging settings.
|
|
@@ -101,13 +102,13 @@ def configure_logging(
|
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
def get_logger(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
project_name: str,
|
|
106
|
+
extra: Optional[dict[str, Any]] = None,
|
|
107
|
+
log_format: str = "%(asctime)s | %(levelname)-10s(l.%(levelno)s) | %(filename)s:%(lineno)s | %(message)s",
|
|
108
|
+
log_level: int = logging.INFO,
|
|
109
|
+
log_file: str = None,
|
|
110
|
+
console_output: bool = True,
|
|
111
|
+
utc: bool = False,
|
|
111
112
|
) -> CustomLoggerAdapter[Logger | LoggerAdapter[Any] | Any] | Logger:
|
|
112
113
|
"""
|
|
113
114
|
Get a named logger with optional extra context.
|
|
@@ -144,3 +145,12 @@ def get_logger(
|
|
|
144
145
|
logger.setLevel(log_level)
|
|
145
146
|
|
|
146
147
|
return CustomLoggerAdapter(logger, extra)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def json_pretty_format(
|
|
151
|
+
data: any,
|
|
152
|
+
indent: int = 4,
|
|
153
|
+
sort_keys: bool = True,
|
|
154
|
+
default: callable = None
|
|
155
|
+
) -> str:
|
|
156
|
+
return json.dumps(data, indent=indent, sort_keys=sort_keys, default=default)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/custom_python_logger/usage_example.py
RENAMED
|
File without changes
|
{custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/custom_python_logger.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{custom_python_logger-1.0.3 → custom_python_logger-1.0.4}/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
|