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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simpler-logging
3
- Version: 1.2.1
3
+ Version: 1.2.2
4
4
  Summary: Simple zero-setup logging.
5
5
  Keywords: logging,logger,simple,zero-setup
6
6
  Author: minoupower554
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "simpler-logging"
3
- version = "1.2.1"
3
+ version = "1.2.2"
4
4
  description = "Simple zero-setup logging."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -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