X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fsfalogging.py;h=5a9745cfb782e522bf35e47a2861f031bf0aa518;hb=3147e8e089dd44e40b852cc121483189807ffa9b;hp=e4b37c8adc976c6fdbf48c3f2f18f137f73223e4;hpb=479fe75aba4509060c663c0025dac7398269f7ff;p=sfa.git diff --git a/sfa/util/sfalogging.py b/sfa/util/sfalogging.py index e4b37c8a..5a9745cf 100644 --- a/sfa/util/sfalogging.py +++ b/sfa/util/sfalogging.py @@ -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')