diff --git a/hotsos/core/config.py b/hotsos/core/config.py index 8875e0c15..236cc779a 100644 --- a/hotsos/core/config.py +++ b/hotsos/core/config.py @@ -119,11 +119,11 @@ def __init__(self): "you want to run a single scenario. " "Useful for testing/debugging"), default_value='', value_type=str)) - self.add(ConfigOpt(name='log_levels', - description=("Log levels for " + self.add(ConfigOpt(name='debug_log_levels', + description=("Debug mode log levels for " "submodules/dependencies"), default_value={'propertree': 'WARNING', - 'searchkit': 'INFO'}, + 'searchkit': 'DEBUG'}, value_type=dict)) @property diff --git a/hotsos/core/log.py b/hotsos/core/log.py index 668903cde..6a8ea7e53 100644 --- a/hotsos/core/log.py +++ b/hotsos/core/log.py @@ -48,11 +48,17 @@ def setup_deps_loggers(self): logger.removeHandler(logger.handlers[0]) logger.addHandler(self._handler) - level = HotSOSConfig.log_levels.get(dep, 'WARNING') - logger.setLevel(level=level) + if HotSOSConfig.debug_mode: + level = HotSOSConfig.debug_log_levels.get(dep, 'WARNING') + logger.setLevel(level=level) + + def start(self, level=None): + if level is None and HotSOSConfig.debug_mode: + level = logging.DEBUG + + if level is not None: + log.setLevel(level) - def start(self, level=logging.DEBUG): - log.setLevel(level) if log.hasHandlers(): return diff --git a/tests/unit/utils.py b/tests/unit/utils.py index f522c13f2..6db4b948e 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -424,7 +424,9 @@ def __init__(self, *args, **kwargs): 'plugin_tmp_dir': None, 'use_all_logs': True, 'machine_readable': True, - 'debug_mode': True} + 'debug_mode': True, + 'debug_log_levels': {'propertree': 'WARNING', + 'searchkit': 'INFO'}} def part_output_to_actual(self, output): actual = {} @@ -446,7 +448,7 @@ def setUp(self): HotSOSConfig.plugin_tmp_dir = self.plugin_tmp_dir if os.environ.get('TESTS_LOG_LEVEL_DEBUG', 'no') == 'yes': - LoggingManager().start(level=logging.DEBUG) + LoggingManager().start() else: LoggingManager().start(level=logging.WARNING)