diff --git a/NEWS b/NEWS index 9714af56..26948a57 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +1.4.14 + * Show summary log errors regardless of verbosity level, and log the "summary:" header with a log + level based on the contained summary logs. + 1.4.13 * Show full error logs at "--verbosity 0" so you can see command output without upping the verbosity level. diff --git a/borgmatic/commands/borgmatic.py b/borgmatic/commands/borgmatic.py index 17f95af4..44b71287 100644 --- a/borgmatic/commands/borgmatic.py +++ b/borgmatic/commands/borgmatic.py @@ -392,11 +392,9 @@ def make_error_log_records(message, error=None): except CalledProcessError as error: yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=message) if error.output: + # Suppress these logs for now and save full error output for the log summary at the end. yield log_record( - levelno=logging.CRITICAL, - levelname='CRITICAL', - msg=error.output, - suppress_log=bool(logger.getEffectiveLevel() < logging.WARNING), + levelno=logging.CRITICAL, levelname='CRITICAL', msg=error.output, suppress_log=True ) yield log_record(levelno=logging.CRITICAL, levelname='CRITICAL', msg=error) except (ValueError, OSError) as error: @@ -543,16 +541,18 @@ def main(): # pragma: no cover logger.debug('Ensuring legacy configuration is upgraded') convert.guard_configuration_upgraded(LEGACY_CONFIG_PATH, config_filenames) - summary_logs = list(collect_configuration_run_summary_logs(configs, arguments)) + summary_logs = parse_logs + list(collect_configuration_run_summary_logs(configs, arguments)) + summary_logs_max_level = max(log.levelno for log in summary_logs) - if logger.getEffectiveLevel() < logging.WARNING: - logger.info('') - logger.info('summary:') - [ - logger.handle(log) - for log in parse_logs + summary_logs - if log.levelno >= logger.getEffectiveLevel() - ] + for message in ('', 'summary:'): + log_record( + levelno=summary_logs_max_level, + levelname=logging.getLevelName(summary_logs_max_level), + msg=message, + ) - if any(log.levelno == logging.CRITICAL for log in summary_logs): + for log in summary_logs: + logger.handle(log) + + if summary_logs_max_level >= logging.CRITICAL: exit_with_help_link() diff --git a/setup.py b/setup.py index 081d5bfe..dfa85e81 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = '1.4.13' +VERSION = '1.4.14' setup( diff --git a/tests/unit/commands/test_borgmatic.py b/tests/unit/commands/test_borgmatic.py index c4e47ffa..6b0bd68c 100644 --- a/tests/unit/commands/test_borgmatic.py +++ b/tests/unit/commands/test_borgmatic.py @@ -119,6 +119,10 @@ def test_log_record_does_not_raise(): module.log_record(levelno=1, foo='bar', baz='quux') +def test_log_record_with_suppress_does_not_raise(): + module.log_record(levelno=1, foo='bar', baz='quux', suppress_log=True) + + def test_make_error_log_records_generates_output_logs_for_message_only(): flexmock(module).should_receive('log_record').replace_with(dict)