From 1023b759e6b48f95b321a60b3bbb4f7c179ab4ce Mon Sep 17 00:00:00 2001 From: Andreas Hubel Date: Thu, 17 Oct 2024 00:10:59 +0200 Subject: [PATCH] chore: refactor logger --- voc/logger.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/voc/logger.py b/voc/logger.py index e37862a..82b5e18 100644 --- a/voc/logger.py +++ b/voc/logger.py @@ -1,14 +1,26 @@ import logging from logging import info, debug, warn, error, critical # noqa +import argparse __all__ = [info, debug, warn, error, critical] - class Logger(logging.Logger): - def __init__(name, *args): - logging.Logger.__init__(name, *args) + def __init__(self, name, args=None, level='INFO'): + logging.Logger.__init__(self, name, level) # log = logging.getLogger(name) + if False and args is None: + parser = argparse.ArgumentParser() + parser.add_argument('--quiet', action='store_true') + parser.add_argument('--debug', action='store_true') + parser.add_argument('--verbose', '-v', action='store_true') + args = parser.parse_args() + + if args: + configure_logging(args) + + + def configure_logging(args): verbosity = (args.verbose or args.debug or 0) - (args.quiet or 0) @@ -35,4 +47,4 @@ def configure_logging(args): else: log_format = '%(asctime)s - %(levelname)s - %(message)s' - logging.basicConfig(filename=args.logfile, level=level, format=log_format) + #logging.basicConfig(filename=args.logfile, level=level, format=log_format)