diff --git a/aprsd/conf/log.py b/aprsd/conf/log.py index f74d513..bb29b38 100644 --- a/aprsd/conf/log.py +++ b/aprsd/conf/log.py @@ -7,47 +7,52 @@ import logging from oslo_config import cfg LOG_LEVELS = { - "CRITICAL": logging.CRITICAL, - "ERROR": logging.ERROR, - "WARNING": logging.WARNING, - "INFO": logging.INFO, - "DEBUG": logging.DEBUG, + 'CRITICAL': logging.CRITICAL, + 'ERROR': logging.ERROR, + 'WARNING': logging.WARNING, + 'INFO': logging.INFO, + 'DEBUG': logging.DEBUG, } -DEFAULT_DATE_FORMAT = "%m/%d/%Y %I:%M:%S %p" +DEFAULT_DATE_FORMAT = '%m/%d/%Y %I:%M:%S %p' DEFAULT_LOG_FORMAT = ( - "[%(asctime)s] [%(threadName)-20.20s] [%(levelname)-5.5s]" - " %(message)s - [%(pathname)s:%(lineno)d]" + '[%(asctime)s] [%(threadName)-20.20s] [%(levelname)-5.5s]' + ' %(message)s - [%(pathname)s:%(lineno)d]' ) DEFAULT_LOG_FORMAT = ( - "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | " - "<yellow>{thread.name: <18}</yellow> | " - "<level>{level: <8}</level> | " - "<level>{message}</level> | " - "<cyan>{name}</cyan>:<cyan>{function:}</cyan>:<magenta>{line:}</magenta>" + '<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | ' + '<yellow>{thread.name: <18}</yellow> | ' + '<level>{level: <8}</level> | ' + '<level>{message}</level> | ' + '<cyan>{name}</cyan>:<cyan>{function:}</cyan>:<magenta>{line:}</magenta>' ) logging_group = cfg.OptGroup( - name="logging", - title="Logging options", + name='logging', + title='Logging options', ) logging_opts = [ cfg.StrOpt( - "logfile", + 'logfile', default=None, - help="File to log to", + help='File to log to', ), cfg.StrOpt( - "logformat", + 'logformat', default=DEFAULT_LOG_FORMAT, - help="Log file format, unless rich_logging enabled.", + help='Log file format, unless rich_logging enabled.', ), cfg.StrOpt( - "log_level", - default="INFO", + 'log_level', + default='INFO', choices=LOG_LEVELS.keys(), - help="Log level for logging of events.", + help='Log level for logging of events.', + ), + cfg.BoolOpt( + 'enable_color', + default=True, + help='Enable ANSI color codes in logging', ), ] diff --git a/aprsd/log/log.py b/aprsd/log/log.py index f80ebe8..b014b59 100644 --- a/aprsd/log/log.py +++ b/aprsd/log/log.py @@ -89,7 +89,7 @@ def setup_logging(loglevel=None, quiet=False): 'sink': sys.stdout, 'serialize': False, 'format': CONF.logging.logformat, - 'colorize': True, + 'colorize': CONF.logging.enable_color, 'level': log_level, }, ]