Skip to content

Commit

Permalink
chore: refactor logger
Browse files Browse the repository at this point in the history
  • Loading branch information
saerdnaer committed Oct 16, 2024
1 parent 6b3d484 commit 1023b75
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions voc/logger.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)

0 comments on commit 1023b75

Please sign in to comment.