From 0c911454ac7f8377003a5f0d90244aa3f06b2695 Mon Sep 17 00:00:00 2001 From: kaliko Date: Mon, 9 Feb 2015 14:52:57 +0100 Subject: [PATCH] Rework 6538573, actually fixes the issue --- sima/launch.py | 2 -- sima/lib/logger.py | 15 +++------------ sima/utils/utils.py | 4 ++-- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/sima/launch.py b/sima/launch.py index c2dad9e..2e2d1dd 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -81,8 +81,6 @@ def start(sopt, restart=False): """ # set logger verbosity = sopt.options.get('verbosity', 'warning') - logfile = sopt.options.get('logfile', None) - set_logger(verbosity, logfile) # loads configuration config = ConfMan(sopt.options).config logfile = config.get('log', 'logfile') diff --git a/sima/lib/logger.py b/sima/lib/logger.py index f156933..09d7a69 100644 --- a/sima/lib/logger.py +++ b/sima/lib/logger.py @@ -38,15 +38,6 @@ LOG_FORMATS = { DATE_FMT = "%Y-%m-%d %H:%M:%S" -class LevelFilter(logging.Filter): - """ - Enable logging between two log level by filtering everything < level. - """ - def filter(self, record): - """Defines loglevel""" - return record.levelno <= ERROR - - def set_logger(level='info', logfile=None): """ logger: @@ -88,10 +79,10 @@ def set_logger(level='info', logfile=None): return # create console handler with a specified log level (STDOUT) couth = logging.StreamHandler(sys.stdout) - couth.addFilter(LevelFilter()) + couth.addFilter(lambda record: record.levelno < ERROR) # create console handler with warning log level (STDERR) - cerrh = logging.StreamHandler() + cerrh = logging.StreamHandler(sys.stderr) cerrh.setLevel(ERROR) # add formatter to the handlers @@ -100,7 +91,7 @@ def set_logger(level='info', logfile=None): # add the handlers to SIMA_LOGGER logger.addHandler(couth) - #logger.addHandler(cerrh) # Already added creating the handler‽ Still have to figure it out. + logger.addHandler(cerrh) # Already added creating the handler‽ Still have to figure it out. # VIM MODLINE # vim: ai ts=4 sw=4 sts=4 expandtab diff --git a/sima/utils/utils.py b/sima/utils/utils.py index 2cb7c35..8a63f1b 100644 --- a/sima/utils/utils.py +++ b/sima/utils/utils.py @@ -22,6 +22,7 @@ """ # pylint: disable=C0111 +import logging import traceback import sys @@ -69,8 +70,7 @@ def normalize_path(path): def exception_log(): """Log unknown exceptions""" - import logging - log = logging.getLogger('sima') + log = logging.getLogger(__name__) log.error('Unhandled Exception!!!') log.error(''.join(traceback.format_exc())) log.info('Please report the previous message' -- 2.39.5