diff --git a/NEWS b/NEWS index c9531b0e..c6123601 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,8 @@ 1.8.4.dev0 - * Add a monitoring hook for sending backup status to a variety of monitoring services via the + * #715: Add a monitoring hook for sending backup status to a variety of monitoring services via the Apprise library. See the documentation for more information: https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/#apprise-hook + * #768: Fix a traceback when an invalid command-line flag or action is used. 1.8.3 * #665: BREAKING: Simplify logging logic as follows: Syslog verbosity is now disabled by diff --git a/borgmatic/logger.py b/borgmatic/logger.py index 5fb67f39..97039249 100644 --- a/borgmatic/logger.py +++ b/borgmatic/logger.py @@ -166,6 +166,8 @@ def configure_logging( Raise FileNotFoundError or PermissionError if the log file could not be opened for writing. ''' + add_custom_log_levels() + if syslog_log_level is None: syslog_log_level = logging.DISABLED if log_file_log_level is None: @@ -173,8 +175,6 @@ def configure_logging( if monitoring_log_level is None: monitoring_log_level = console_log_level - add_custom_log_levels() - # Log certain log levels to console stderr and others to stdout. This supports use cases like # grepping (non-error) output. console_disabled = logging.NullHandler() diff --git a/tests/end-to-end/test_invalid_flag.py b/tests/end-to-end/test_invalid_flag.py new file mode 100644 index 00000000..a813dbf2 --- /dev/null +++ b/tests/end-to-end/test_invalid_flag.py @@ -0,0 +1,11 @@ +import subprocess +import sys + + +def test_borgmatic_command_with_invalid_flag_shows_error_but_not_traceback(): + output = subprocess.run( + 'borgmatic -v 2 --invalid'.split(' '), stdout=subprocess.PIPE, stderr=subprocess.STDOUT + ).stdout.decode(sys.stdout.encoding) + + assert 'Unrecognized argument' in output + assert 'Traceback' not in output