X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fsfalogging.py;h=078935348ba969613a4934903a97d8b7e3130df4;hb=31cc4fa991896f000abb106916662923f37bc3a6;hp=e4b37c8adc976c6fdbf48c3f2f18f137f73223e4;hpb=479fe75aba4509060c663c0025dac7398269f7ff;p=sfa.git diff --git a/sfa/util/sfalogging.py b/sfa/util/sfalogging.py index e4b37c8a..07893534 100644 --- a/sfa/util/sfalogging.py +++ b/sfa/util/sfalogging.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2 """ A reroutable logger that can handle deep tracebacks @@ -123,7 +123,7 @@ def logging_config(context): if context == 'server': handlername = 'file' filename = '/var/log/sfa.log' - level = 'INFO' + level = 'DEBUG' elif context == 'import': handlername = 'file' filename = '/var/log/sfa-import.log' @@ -140,7 +140,7 @@ def logging_config(context): print("Cannot configure logging - exiting") exit(1) - return { + config = { 'version': 1, # IMPORTANT: we may be imported by something else, so: 'disable_existing_loggers': False, @@ -151,23 +151,9 @@ def logging_config(context): '%(filename)s:%(lineno)d %(message)s'), }, }, + # fill in later with just the one needed + # otherwise a dummy 'ignored' file gets created 'handlers': { - 'file': { - 'filename': filename, - 'level': level, - 'formatter': 'standard', - 'class': 'logging.handlers.TimedRotatingFileHandler', - # every monday and during 3 months - 'when': 'w0', - 'interval': 1, - 'backupCount': 12, - - }, - 'stdout': { - 'level': level, - 'formatter': 'standard', - 'class': 'logging.StreamHandler', - }, }, 'loggers': { 'sfa': { @@ -177,6 +163,24 @@ def logging_config(context): }, }, } + if handlername == 'stdout': + config['handlers']['stdout'] = { + 'level': level, + 'formatter': 'standard', + 'class': 'logging.StreamHandler', + } + else: + config['handlers']['file'] = { + 'filename': filename, + 'level': level, + 'formatter': 'standard', + 'class': 'logging.handlers.TimedRotatingFileHandler', + # every monday and during 3 months + 'when': 'w0', + 'interval': 1, + 'backupCount': 12, + } + return config logger = logging.getLogger('sfa')