From cb821b119b43ac940ff6960c1c8140f30de8f6c8 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 8 Dec 2015 01:37:34 +0100 Subject: [PATCH] remove --log-level, add --debug and --info option, update docs removed --log-level due to overlap with how --verbose works now. for consistency, added --info as alias to --verbose (as the effect is setting INFO log level). also added --debug which sets DEBUG log level. note: there are no messages emitted at DEBUG level yet. WARNING is the default (because we want mostly silent behaviour, except if something serious happens), so we don't need --warning as an option. --- borg/archiver.py | 10 +++++----- borg/testsuite/archiver.py | 6 +++--- docs/changes.rst | 4 +++- docs/usage.rst | 16 ++++++++++++---- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index fe9813d2f..39ecaaa24 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -664,12 +664,12 @@ class Archiver: def build_parser(self, args=None, prog=None): common_parser = argparse.ArgumentParser(add_help=False, prog=prog) - common_parser.add_argument('-v', '--verbose', dest='log_level', + common_parser.add_argument('-v', '--verbose', '--info', dest='log_level', action='store_const', const='info', default='warning', - help='verbose output, same as --log-level=info') - common_parser.add_argument('--log-level', dest='log_level', default='warning', metavar='LEVEL', - choices=('debug', 'info', 'warning', 'error', 'critical'), - help='set the log level to LEVEL, default: %(default)s)') + help='enable informative (verbose) output, work on log level INFO') + common_parser.add_argument('--debug', dest='log_level', + action='store_const', const='debug', default='warning', + help='enable debug output, work on log level DEBUG') common_parser.add_argument('--lock-wait', dest='lock_wait', type=int, metavar='N', default=1, help='wait for the lock, but max. N seconds (default: %(default)d).') common_parser.add_argument('--show-rc', dest='show_rc', action='store_true', default=False, diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py index 8e24671b9..0698befc5 100644 --- a/borg/testsuite/archiver.py +++ b/borg/testsuite/archiver.py @@ -950,13 +950,13 @@ class ArchiverCheckTestCase(ArchiverTestCaseBase): return archive, repository def test_check_usage(self): - output = self.cmd('check', '--log-level=info', self.repository_location, exit_code=0) + output = self.cmd('check', '-v', self.repository_location, exit_code=0) self.assert_in('Starting repository check', output) self.assert_in('Starting archive consistency check', output) - output = self.cmd('check', '--log-level=info', '--repository-only', self.repository_location, exit_code=0) + output = self.cmd('check', '-v', '--repository-only', self.repository_location, exit_code=0) self.assert_in('Starting repository check', output) self.assert_not_in('Starting archive consistency check', output) - output = self.cmd('check', '--log-level=info', '--archives-only', self.repository_location, exit_code=0) + output = self.cmd('check', '-v', '--archives-only', self.repository_location, exit_code=0) self.assert_not_in('Starting repository check', output) self.assert_in('Starting archive consistency check', output) diff --git a/docs/changes.rst b/docs/changes.rst index d87dba7dd..712e89989 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -25,7 +25,9 @@ New features: - implement borg break-lock command, fixes #157 - include system info below traceback, fixes #324 - use ISO-8601 date and time format, fixes #375 -- add --log-level to set the level of the builtin logging configuration, fixes #426 +- add --debug and --info (same as --verbose) to set the log level of the + builtin logging configuration (which otherwise defaults to warning), + fixes #426 - configure logging via env var BORG_LOGGING_CONF - add a --no-progress flag to forcibly disable progress info diff --git a/docs/usage.rst b/docs/usage.rst index 9367791c4..1d31d6e5f 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -14,12 +14,20 @@ General Type of log output ~~~~~~~~~~~~~~~~~~ -You can set the log level of the builtin logging configuration using the ---log-level option. +The log level of the builtin logging configuration defaults to WARNING. +This is because we want |project_name| to be mostly silent and only output +warnings (plus errors and critical messages). -Supported levels: ``debug``, ``info``, ``warning``, ``error``, ``critical``. +Use --verbose or --info to set INFO (you will get informative output then +additionally to warnings, errors, critical messages). +Use --debug to set DEBUG to get output made for debugging. -All log messages created with at least the given level will be output. +All log messages created with at least the set level will be output. + +Log levels: DEBUG < INFO < WARNING < ERROR < CRITICAL + +While you can set misc. log levels, do not expect that every command will +give different output on different log levels - it's just a possibility. Return codes ~~~~~~~~~~~~