Skip to content

Commit

Permalink
Re-align logging levels for file vs. stdout
Browse files Browse the repository at this point in the history
For both we want to default to DEBUG and still allow
unit tests to override.
  • Loading branch information
dosaboy committed Apr 29, 2024
1 parent 067d034 commit ef161b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
3 changes: 2 additions & 1 deletion hotsos/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def __init__(self):
description='Version of hotsos being run.',
default_value=None, value_type=str))
self.add(ConfigOpt(name='debug_mode',
description='Set to True to enable debug logging',
description='Set to True to enable debug logging '
'to standard output',
default_value=False, value_type=bool))
self.add(ConfigOpt(name='plugin_yaml_defs',
description='Path to yaml-defined checks.',
Expand Down
14 changes: 4 additions & 10 deletions hotsos/core/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,11 @@ def setup_deps_loggers(self):
logger.removeHandler(logger.handlers[0])

logger.addHandler(self._handler)
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)
level = HotSOSConfig.debug_log_levels.get(dep, 'WARNING')
logger.setLevel(level=level)

def start(self, level=logging.DEBUG):
log.setLevel(level)
if log.hasHandlers():
return

Expand Down
5 changes: 2 additions & 3 deletions tests/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,7 @@ def __init__(self, *args, **kwargs):
'plugin_tmp_dir': None,
'use_all_logs': True,
'machine_readable': True,
'debug_mode': True,
'debug_log_levels': {'propertree': 'WARNING',
'searchkit': 'INFO'}}
'debug_mode': True}

def part_output_to_actual(self, output):
actual = {}
Expand All @@ -450,6 +448,7 @@ def setUp(self):
if os.environ.get('TESTS_LOG_LEVEL_DEBUG', 'no') == 'yes':
LoggingManager().start()
else:
HotSOSConfig.debug_log_levels['searchkit'] = 'WARNING'
LoggingManager().start(level=logging.WARNING)

def _addDuration(self, *args, **kwargs): # For Python >= 3.12
Expand Down

0 comments on commit ef161b5

Please sign in to comment.