"""
# 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')
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:
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
# 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
"""
# pylint: disable=C0111
+import logging
import traceback
import sys
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'