simpler-logging 1.2.1__tar.gz → 1.2.2__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.
- {simpler_logging-1.2.1 → simpler_logging-1.2.2}/PKG-INFO +1 -1
- {simpler_logging-1.2.1 → simpler_logging-1.2.2}/pyproject.toml +1 -1
- {simpler_logging-1.2.1 → simpler_logging-1.2.2}/src/simpler_logging/logger.py +4 -1
- {simpler_logging-1.2.1 → simpler_logging-1.2.2}/LICENSE +0 -0
- {simpler_logging-1.2.1 → simpler_logging-1.2.2}/README.md +0 -0
- {simpler_logging-1.2.1 → simpler_logging-1.2.2}/src/simpler_logging/__init__.py +0 -0
- {simpler_logging-1.2.1 → simpler_logging-1.2.2}/src/simpler_logging/py.typed +0 -0
|
@@ -24,9 +24,10 @@ class Handler(Protocol):
|
|
|
24
24
|
def __call__(self, *, level: LogLevel, msg: str, logger_name: str, do_color: bool) -> None:
|
|
25
25
|
...
|
|
26
26
|
|
|
27
|
+
_max_logger_name: int = 0
|
|
27
28
|
|
|
28
29
|
def main_handler(level: str, color: int | str, msg: str, logger_name: str):
|
|
29
|
-
print(f"{color}{Style.DIM}[{datetime.now().astimezone().isoformat(timespec='milliseconds')}]{color} {level:<5} {Style.DIM}{logger_name}{color}: {msg}{Style.RESET_ALL}")
|
|
30
|
+
print(f"{color}{Style.DIM}[{datetime.now().astimezone().isoformat(timespec='milliseconds')}]{color} {level:<5} {Style.DIM}{logger_name:<{_max_logger_name}}{color}: {msg}{Style.RESET_ALL}")
|
|
30
31
|
|
|
31
32
|
def default_handler(*, level: LogLevel, msg: str, logger_name: str, do_color: bool):
|
|
32
33
|
if level == LogLevel.DEBUG:
|
|
@@ -57,6 +58,8 @@ class Logger:
|
|
|
57
58
|
LogLevel.WARN: default_handler, LogLevel.ERROR: default_handler,
|
|
58
59
|
LogLevel.FATAL: default_handler}
|
|
59
60
|
self._do_color = True
|
|
61
|
+
global _max_logger_name
|
|
62
|
+
_max_logger_name = max(_max_logger_name, len(name))
|
|
60
63
|
|
|
61
64
|
def log(self, level: LogLevel, msg: str, *args, **kwargs) -> None:
|
|
62
65
|
"""Log a message taking into account the active levels. Generally you should use the dedicated per-level log methods instead."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|