Change log time format to include ms
This commit is contained in:
parent
0d823b26b9
commit
ff65c1316e
1 changed files with 6 additions and 2 deletions
|
@ -4,7 +4,9 @@ import logging
|
|||
from rich.logging import RichHandler
|
||||
|
||||
|
||||
def get_logger(name: str, show_locals: bool = False) -> logging.Logger:
|
||||
def get_logger(
|
||||
name: str, show_locals: bool = False, format: str = "%x %H:%M:%S.%f"
|
||||
) -> logging.Logger:
|
||||
"""
|
||||
Get a pre-configured logger
|
||||
|
||||
|
@ -12,6 +14,8 @@ def get_logger(name: str, show_locals: bool = False) -> logging.Logger:
|
|||
name: Name of the logger
|
||||
"""
|
||||
logger = logging.getLogger(name)
|
||||
handler = RichHandler(rich_tracebacks=True, tracebacks_show_locals=show_locals)
|
||||
handler = RichHandler(
|
||||
rich_tracebacks=True, tracebacks_show_locals=show_locals, log_time_format="[{format}]"
|
||||
)
|
||||
logger.addHandler(handler)
|
||||
return logger
|
||||
|
|
Loading…
Add table
Reference in a new issue