Skip to content

Commit

Permalink
Tweak dependency debug log levels
Browse files Browse the repository at this point in the history
These are only set when debug mode is True so
make that clearer by calling the config
debug_log_levels. Also change default searchkit
debug log level to DEBUG since all logs are
currently at that level.
  • Loading branch information
dosaboy committed Apr 29, 2024
1 parent 7ebf6ef commit 067d034
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
6 changes: 3 additions & 3 deletions hotsos/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions hotsos/core/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions tests/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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)

Expand Down

0 comments on commit 067d034

Please sign in to comment.