I'm trying to use this code in my app:
def logger(log_file='base.log', set_level='INFO', identity='base'):
set_level = get_settings().logging_setLevel
if log_file:
log_path = os.path.join(os.path.expanduser('~'), '/mnt/logs/')
if not os.path.exists(log_path):
os.makedirs(log_path)
handler = logging.FileHandler(log_path+log_file)
else:
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - '+ identity +' - %(levelname)s - %(message)s', '%Y-%m-%dT%H:%M:%SZ')
handler.setFormatter(formatter)
logger = logging.getLogger(identity)
logger.addHandler(handler)
logger.setLevel(eval("logging." + set_level))
return logger
But the problem is regardless what level I choose in set_level
argument it still produces all levels ('DEBUG' and so on....).
Can you please help me identify the problem.