From ebab15285e7d44435a1f255d4a8edc00edd1ce61 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 4 Dec 2012 12:59:49 +0000 Subject: [PATCH] Reduced logging level to trace. * In order to do the above, we switch the standard library's logging logger class as soon as possible with our own version which includes `trace()` and `garbage()`. Might also fix saltstack/salt-cloud#186. --- salt/loader.py | 3 +-- salt/log.py | 27 ++++++++++----------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/salt/loader.py b/salt/loader.py index f6ebc91521..c92cc50554 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -615,8 +615,7 @@ class Loader(object): # now that callable passes all the checks, add it to the # library of available functions of this type funcs[attr_name] = func - log.debug('Added {0} to {1}'.format(attr_name, - self.tag)) + log.trace('Added {0} to {1}'.format(attr_name, self.tag)) self._apply_outputter(func, mod) # now that all the functions have been collected, iterate back over diff --git a/salt/log.py b/salt/log.py index 72c13a84b4..14122dad4c 100644 --- a/salt/log.py +++ b/salt/log.py @@ -106,22 +106,20 @@ class Logging(LoggingLoggerClass): return LoggingLoggerClass.log(self, TRACE, msg, *args, **kwargs) -def getLogger(name): - init() - return logging.getLogger(name) - - -def init(): +if logging.getLoggerClass() is not Logging: ''' Replace the default system logger with a version that includes trace() and garbage() methods. ''' - if logging.getLoggerClass() is not Logging: - logging.setLoggerClass(Logging) - logging.addLevelName(TRACE, 'TRACE') - logging.addLevelName(GARBAGE, 'GARBAGE') - # Set the root logger at the lowest level possible - logging.getLogger().setLevel(GARBAGE) + logging.setLoggerClass(Logging) + logging.addLevelName(TRACE, 'TRACE') + logging.addLevelName(GARBAGE, 'GARBAGE') + # Set the root logger at the lowest level possible + logging.getLogger().setLevel(GARBAGE) + + +def getLogger(name): + return logging.getLogger(name) def setup_console_logger(log_level='error', log_format=None, date_format=None): @@ -132,8 +130,6 @@ def setup_console_logger(log_level='error', log_format=None, date_format=None): logging.getLogger(__name__).warn('Console logging already configured') return - init() - if log_level is None: log_level = 'warning' @@ -183,8 +179,6 @@ def setup_logfile_logger(log_path, log_level='error', log_format=None, logging.getLogger(__name__).warn('Logfile logging already configured') return - init() - if log_level is None: log_level = 'warning' @@ -295,7 +289,6 @@ def set_logger_level(logger_name, log_level='error'): ''' Tweak a specific logger's logging level ''' - init() logging.getLogger(logger_name).setLevel( LOG_LEVELS.get(log_level.lower(), logging.ERROR) )