custom-python-logger 3.0.0__tar.gz → 3.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-3.0.0/custom_python_logger.egg-info → custom_python_logger-3.0.1}/PKG-INFO +1 -1
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger/logger.py +12 -26
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1/custom_python_logger.egg-info}/PKG-INFO +1 -1
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/pyproject.toml +1 -1
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/LICENSE +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/MANIFEST.in +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/README.md +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger/__init__.py +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger/consts.py +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger.egg-info/SOURCES.txt +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger.egg-info/dependency_links.txt +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger.egg-info/requires.txt +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger.egg-info/top_level.txt +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/setup.cfg +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/tests/test_logger.py +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/tests/test_logger_pytest.py +0 -0
- {custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/tests/test_usage_example_pytest.py +0 -0
|
@@ -80,11 +80,7 @@ def clear_existing_handlers(logger: Logger) -> None:
|
|
|
80
80
|
logger.removeHandler(handler)
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
def
|
|
84
|
-
logger: Logger,
|
|
85
|
-
log_file_path: str | None,
|
|
86
|
-
log_format: str,
|
|
87
|
-
) -> None:
|
|
83
|
+
def add_file_handler(logger: Logger, log_file_path: str | None, log_format: str) -> None:
|
|
88
84
|
if log_file_path is not None:
|
|
89
85
|
log_file_formatter = logging.Formatter(log_format)
|
|
90
86
|
|
|
@@ -96,16 +92,15 @@ def add_file_handler_if_specified(
|
|
|
96
92
|
logger.addHandler(file_handler)
|
|
97
93
|
|
|
98
94
|
|
|
99
|
-
def
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
)
|
|
95
|
+
def add_console_handler(logger: Logger, log_format: str) -> None:
|
|
96
|
+
log_console_formatter = ColoredFormatter(
|
|
97
|
+
"%(log_color)s " + log_format,
|
|
98
|
+
log_colors=LOG_COLORS,
|
|
99
|
+
)
|
|
105
100
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
console_handler = logging.StreamHandler()
|
|
102
|
+
console_handler.setFormatter(log_console_formatter)
|
|
103
|
+
logger.addHandler(console_handler)
|
|
109
104
|
|
|
110
105
|
|
|
111
106
|
def get_logger(name: str, log_level: int | None = None, extra: dict | None = None) -> CustomLoggerAdapter:
|
|
@@ -150,25 +145,16 @@ def build_logger( # pylint: disable=R0913
|
|
|
150
145
|
logging.Formatter.converter = time.gmtime
|
|
151
146
|
|
|
152
147
|
root_logger = logging.getLogger()
|
|
153
|
-
|
|
154
148
|
clear_existing_handlers(logger=root_logger)
|
|
155
149
|
|
|
156
|
-
|
|
157
|
-
logger=root_logger,
|
|
158
|
-
console_output=console_output,
|
|
159
|
-
log_format=log_format,
|
|
160
|
-
)
|
|
150
|
+
if console_output:
|
|
151
|
+
add_console_handler(logger=root_logger, log_format=log_format)
|
|
161
152
|
|
|
162
153
|
if log_file:
|
|
163
154
|
if not log_file_path:
|
|
164
155
|
log_file_path = f"{get_project_path_by_file()}/logs/{project_name}.log"
|
|
165
156
|
log_file_path = log_file_path.lower().replace(" ", "_")
|
|
166
|
-
|
|
167
|
-
add_file_handler_if_specified(
|
|
168
|
-
logger=root_logger,
|
|
169
|
-
log_file_path=log_file_path,
|
|
170
|
-
log_format=log_format,
|
|
171
|
-
)
|
|
157
|
+
add_file_handler(logger=root_logger, log_file_path=log_file_path, log_format=log_format)
|
|
172
158
|
|
|
173
159
|
logger = CustomLoggerAdapter(logging.getLogger(CUSTOM_LOGGER), extra)
|
|
174
160
|
logger.setLevel(log_level)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/custom_python_logger.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{custom_python_logger-3.0.0 → custom_python_logger-3.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
|
{custom_python_logger-3.0.0 → custom_python_logger-3.0.1}/tests/test_usage_example_pytest.py
RENAMED
|
File without changes
|