mirror of
https://github.com/Steffo99/unimore-bda-6.git
synced 2025-02-16 14:13:59 +00:00
Allow registration of multiple custom loggers
This commit is contained in:
parent
ab5f12f8fc
commit
b347031663
1 changed files with 27 additions and 23 deletions
|
@ -4,10 +4,14 @@ import coloredlogs
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def install_log_handler(logger: logging.Logger = None):
|
def install_log_handler(loggers: list[logging.Logger] = None):
|
||||||
if logger is None:
|
if loggers is None:
|
||||||
logger = logging.getLogger("unimore_bda_6")
|
loggers = [
|
||||||
|
logging.getLogger("__main__"),
|
||||||
|
logging.getLogger("unimore_bda_6"),
|
||||||
|
]
|
||||||
|
|
||||||
|
for logger in loggers:
|
||||||
coloredlogs.install(
|
coloredlogs.install(
|
||||||
logger=logger,
|
logger=logger,
|
||||||
level="DEBUG",
|
level="DEBUG",
|
||||||
|
@ -27,7 +31,7 @@ def install_log_handler(logger: logging.Logger = None):
|
||||||
),
|
),
|
||||||
isatty=True,
|
isatty=True,
|
||||||
)
|
)
|
||||||
log.info("Installed custom log handler!")
|
log.debug("Installed custom log handler on: %s", logger)
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
|
Loading…
Add table
Reference in a new issue