1
Fork 0
mirror of https://github.com/Steffo99/unimore-bda-6.git synced 2024-11-21 23:44:19 +00:00

Allow registration of multiple custom loggers

This commit is contained in:
Steffo 2023-02-02 04:36:55 +01:00
parent ab5f12f8fc
commit b347031663
Signed by: steffo
GPG key ID: 2A24051445686895

View file

@ -4,10 +4,14 @@ import coloredlogs
log = logging.getLogger(__name__)
def install_log_handler(logger: logging.Logger = None):
if logger is None:
logger = logging.getLogger("unimore_bda_6")
def install_log_handler(loggers: list[logging.Logger] = None):
if loggers is None:
loggers = [
logging.getLogger("__main__"),
logging.getLogger("unimore_bda_6"),
]
for logger in loggers:
coloredlogs.install(
logger=logger,
level="DEBUG",
@ -27,7 +31,7 @@ def install_log_handler(logger: logging.Logger = None):
),
isatty=True,
)
log.info("Installed custom log handler!")
log.debug("Installed custom log handler on: %s", logger)
__all__ = (