1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-06-17 05:42:36 -04:00

Allow passing in a custom handler to setup_logging

This adds the ability to pass in a custom log handler during
startup in the log.setup_logging().
This commit is contained in:
Hemna 2025-03-06 17:09:40 -05:00
parent 7ed8028307
commit d262589313

View File

@ -51,7 +51,7 @@ class InterceptHandler(logging.Handler):
# Setup the log faciility # Setup the log faciility
# to disable log to stdout, but still log to file # to disable log to stdout, but still log to file
# use the --quiet option on the cmdln # use the --quiet option on the cmdln
def setup_logging(loglevel=None, quiet=False): def setup_logging(loglevel=None, quiet=False, custom_handler=None):
if not loglevel: if not loglevel:
log_level = CONF.logging.log_level log_level = CONF.logging.log_level
else: else:
@ -107,6 +107,9 @@ def setup_logging(loglevel=None, quiet=False):
}, },
) )
if custom_handler:
handlers.append(custom_handler)
# configure loguru # configure loguru
logger.configure(handlers=handlers) logger.configure(handlers=handlers)
logger.level('DEBUG', color='<fg #BABABA>') logger.level('DEBUG', color='<fg #BABABA>')