mirror of https://github.com/borgbackup/borg.git
Merge pull request #836 from ThomasWaldmann/complete-log-levels
add --warning, --error, --critical for completeness, fixes #826
This commit is contained in:
commit
e6fff5fe1f
|
@ -818,12 +818,21 @@ class Archiver:
|
||||||
|
|
||||||
def build_parser(self, args=None, prog=None):
|
def build_parser(self, args=None, prog=None):
|
||||||
common_parser = argparse.ArgumentParser(add_help=False, prog=prog)
|
common_parser = argparse.ArgumentParser(add_help=False, prog=prog)
|
||||||
|
common_parser.add_argument('--critical', dest='log_level',
|
||||||
|
action='store_const', const='critical', default='warning',
|
||||||
|
help='work on log level CRITICAL')
|
||||||
|
common_parser.add_argument('--error', dest='log_level',
|
||||||
|
action='store_const', const='error', default='warning',
|
||||||
|
help='work on log level ERROR')
|
||||||
|
common_parser.add_argument('--warning', dest='log_level',
|
||||||
|
action='store_const', const='warning', default='warning',
|
||||||
|
help='work on log level WARNING (default)')
|
||||||
common_parser.add_argument('-v', '--verbose', '--info', dest='log_level',
|
common_parser.add_argument('-v', '--verbose', '--info', dest='log_level',
|
||||||
action='store_const', const='info', default='warning',
|
action='store_const', const='info', default='warning',
|
||||||
help='enable informative (verbose) output, work on log level INFO')
|
help='work on log level INFO')
|
||||||
common_parser.add_argument('--debug', dest='log_level',
|
common_parser.add_argument('--debug', dest='log_level',
|
||||||
action='store_const', const='debug', default='warning',
|
action='store_const', const='debug', default='warning',
|
||||||
help='enable debug output, work on log level DEBUG')
|
help='work on log level DEBUG')
|
||||||
common_parser.add_argument('--lock-wait', dest='lock_wait', type=int, metavar='N', default=1,
|
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).')
|
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,
|
common_parser.add_argument('--show-rc', dest='show_rc', action='store_true', default=False,
|
||||||
|
|
|
@ -195,6 +195,10 @@ class RemoteRepository:
|
||||||
opts.append('--info')
|
opts.append('--info')
|
||||||
elif root_logger.isEnabledFor(logging.WARNING):
|
elif root_logger.isEnabledFor(logging.WARNING):
|
||||||
pass # warning is default
|
pass # warning is default
|
||||||
|
elif root_logger.isEnabledFor(logging.ERROR):
|
||||||
|
opts.append('--error')
|
||||||
|
elif root_logger.isEnabledFor(logging.CRITICAL):
|
||||||
|
opts.append('--critical')
|
||||||
else:
|
else:
|
||||||
raise ValueError('log level missing, fix this code')
|
raise ValueError('log level missing, fix this code')
|
||||||
if testing:
|
if testing:
|
||||||
|
|
|
@ -16,19 +16,31 @@ Type of log output
|
||||||
|
|
||||||
The log level of the builtin logging configuration defaults to WARNING.
|
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
|
This is because we want |project_name| to be mostly silent and only output
|
||||||
warnings (plus errors and critical messages).
|
warnings, errors and critical messages.
|
||||||
|
|
||||||
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 set level will be output.
|
|
||||||
|
|
||||||
Log levels: DEBUG < INFO < WARNING < ERROR < CRITICAL
|
Log levels: DEBUG < INFO < WARNING < ERROR < CRITICAL
|
||||||
|
|
||||||
|
Use ``--debug`` to set DEBUG log level -
|
||||||
|
to get debug, info, warning, error and critical level output.
|
||||||
|
|
||||||
|
Use ``--info`` (or ``-v`` or ``--verbose``) to set INFO log level -
|
||||||
|
to get info, warning, error and critical level output.
|
||||||
|
|
||||||
|
Use ``--warning`` (default) to set WARNING log level -
|
||||||
|
to get warning, error and critical level output.
|
||||||
|
|
||||||
|
Use ``--error`` to set ERROR log level -
|
||||||
|
to get error and critical level output.
|
||||||
|
|
||||||
|
Use ``--critical`` to set CRITICAL log level -
|
||||||
|
to get critical level output.
|
||||||
|
|
||||||
While you can set misc. log levels, do not expect that every command will
|
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.
|
give different output on different log levels - it's just a possibility.
|
||||||
|
|
||||||
|
.. warning:: Options --critical and --error are provided for completeness,
|
||||||
|
their usage is not recommended as you might miss important information.
|
||||||
|
|
||||||
.. warning:: While some options (like ``--stats`` or ``--list``) will emit more
|
.. warning:: While some options (like ``--stats`` or ``--list``) will emit more
|
||||||
informational messages, you have to use INFO (or lower) log level to make
|
informational messages, you have to use INFO (or lower) log level to make
|
||||||
them show up in log output. Use ``-v`` or a logging configuration.
|
them show up in log output. Use ``-v`` or a logging configuration.
|
||||||
|
@ -765,4 +777,4 @@ for e.g. regular pruning.
|
||||||
|
|
||||||
Further protections can be implemented, but are outside of Borgs scope. For example,
|
Further protections can be implemented, but are outside of Borgs scope. For example,
|
||||||
file system snapshots or wrapping ``borg serve`` to set special permissions or ACLs on
|
file system snapshots or wrapping ``borg serve`` to set special permissions or ACLs on
|
||||||
new data files.
|
new data files.
|
||||||
|
|
Loading…
Reference in New Issue