Skip to content

Commit c2bce8e

Browse files
author
Vasileios Karakasis
committed
Merge branch 'master' into internals/bad-check-handling
2 parents a442a52 + f349a3e commit c2bce8e

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

reframe/core/logging.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,14 @@ def setLevel(self, level):
362362
if self.logger:
363363
super().setLevel(level)
364364

365+
@property
366+
def std_stream_handlers(self):
367+
if self.logger:
368+
return [h for h in self.logger.handlers
369+
if h.stream == sys.stdout or h.stream == sys.stderr]
370+
else:
371+
return []
372+
365373
def _update_check_extras(self):
366374
"""Return a dictionary with all the check-specific information."""
367375
if self.check is None:
@@ -431,6 +439,18 @@ def error(self, message, *args, **kwargs):
431439

432440
super().error(message, *args, **kwargs)
433441

442+
def inc_verbosity(self, num_steps):
443+
"""Convenience function for increasing the verbosity
444+
of the logger step-wise."""
445+
log_levels = sorted(_log_level_names.keys())[1:]
446+
for h in self.std_stream_handlers:
447+
level_idx = log_levels.index(h.level)
448+
if level_idx - num_steps < 0:
449+
new_level = log_levels[0]
450+
else:
451+
new_level = log_levels[level_idx - num_steps]
452+
453+
h.setLevel(new_level)
434454

435455

436456
# A logger that doesn't log anything

reframe/frontend/cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def main():
8787
'--save-log-files', action='store_true', default=False,
8888
help='Copy the log file from the work dir to the output dir at the '
8989
'end of the program')
90+
output_options.add_argument(
91+
'--verbose', '-v', action='count', default=0,
92+
help='Increase verbosity level of output')
9093

9194
# Check discovery options
9295
locate_options.add_argument(
@@ -262,6 +265,8 @@ def main():
262265
# Setup printer
263266
printer = PrettyPrinter()
264267
printer.colorize = options.colorize
268+
if options.verbose:
269+
printer.inc_verbosity(options.verbose)
265270

266271
try:
267272
runtime.init_runtime(settings.site_configuration, options.system)

unittests/test_cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,3 +387,13 @@ def test_show_env_config_unknown_env(self):
387387
self.assertNotIn('Traceback', stdout)
388388
self.assertNotIn('Traceback', stderr)
389389
self.assertEqual(1, returncode)
390+
391+
def test_verbosity(self):
392+
self.more_options = ['-vvvvv']
393+
self.system = 'testsys'
394+
self.action = 'list'
395+
returncode, stdout, stderr = self._run_reframe()
396+
self.assertNotEqual('', stdout)
397+
self.assertNotIn('Traceback', stdout)
398+
self.assertNotIn('Traceback', stderr)
399+
self.assertEqual(0, returncode)

0 commit comments

Comments
 (0)