By default only brief logging output at verbosity 1 #283
|
@ -178,16 +178,13 @@ def create_archive(
|
||||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||||
+ (
|
+ (
|
||||||
('--list', '--filter', 'AME-')
|
('--list', '--filter', 'AME-')
|
||||||
if logger.isEnabledFor(logging.INFO)
|
if (files or logger.isEnabledFor(logging.DEBUG)) and not json and not progress
|
||||||
and not json
|
|
||||||
and not progress
|
|
||||||
and (files or logger.isEnabledFor(logging.DEBUG))
|
|
||||||
else ()
|
else ()
|
||||||
)
|
)
|
||||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO and not json else ())
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO and not json else ())
|
||||||
|
|||||||
+ (
|
+ (
|
||||||
('--stats',)
|
('--stats',)
|
||||||
if not dry_run and (logger.isEnabledFor(logging.DEBUG) or stats) and not json
|
if (stats or logger.isEnabledFor(logging.DEBUG)) and not json and not dry_run
|
||||||
else ()
|
else ()
|
||||||
)
|
)
|
||||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) and not json else ())
|
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) and not json else ())
|
||||||
|
@ -211,8 +208,6 @@ def create_archive(
|
||||||
|
|
||||||
if json:
|
if json:
|
||||||
output_log_level = None
|
output_log_level = None
|
||||||
elif stats and logger.getEffectiveLevel() == logging.WARNING:
|
|
||||||
output_log_level = logging.WARNING
|
|
||||||
else:
|
else:
|
||||||
output_log_level = logging.INFO
|
output_log_level = logging.INFO
|
||||||
|
|
||||||
|
|
|
@ -58,23 +58,13 @@ def prune_archives(
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||||
+ (
|
+ (('--stats',) if (stats or logger.isEnabledFor(logging.DEBUG)) and not dry_run else ())
|
||||||
('--stats',)
|
|
||||||
if not dry_run and logger.getEffectiveLevel() == logging.DEBUG or stats
|
|
||||||
else ()
|
|
||||||
)
|
|
||||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||||
+ (('--list',) if logger.getEffectiveLevel() == logging.INFO and files else ())
|
+ (('--list',) if files or logger.isEnabledFor(logging.DEBUG) else ())
|
||||||
witten
commented
Would be good to parenthesize the Would be good to parenthesize the `logger.getEffectiveLevel() == logging.DEBUG or stats` part for clarity.
|
|||||||
+ (('--debug', '--list', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||||
+ (('--dry-run',) if dry_run else ())
|
+ (('--dry-run',) if dry_run else ())
|
||||||
+ (tuple(extra_borg_options.split(' ')) if extra_borg_options else ())
|
+ (tuple(extra_borg_options.split(' ')) if extra_borg_options else ())
|
||||||
+ (repository,)
|
+ (repository,)
|
||||||
witten
commented
Shouldn't this be an Shouldn't this be an `or` rather than an `and`, so `--files` works at multiple log levels? And for `prune`, is the idea that the file listing should still be enabled at `INFO`, rather than demoting it to `DEBUG` like with `create`?
palto42
commented
My intention was to only show the file listing at INFO and not at WARNING level. This is related to the old influence of the To make the code a bit more consistent I moved the
My intention was to only show the file listing at INFO and not at WARNING level. This is related to the old influence of the `--stats` option to change the logging level of the borg output. Since now `--stats`has no influence on the borg output level anymore, I could simplify the condition to `if files`.
To make the code a bit more consistent I moved the `--list`out of extra DEBUG line similar as in `create.py`:
```
+ (('--list',) if files or logger.isEnabledFor(logging.DEBUG) else ())
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
```
witten
commented
Looks good, thanks! Looks good, thanks!
|
|||||||
)
|
)
|
||||||
|
|
||||||
execute_command(
|
execute_command(full_command, output_log_level=logging.INFO, error_on_warnings=False)
|
||||||
full_command,
|
|
||||||
output_log_level=logging.WARNING
|
|
||||||
if (stats and logger.getEffectiveLevel() == logging.WARNING)
|
|
||||||
else logging.INFO,
|
|
||||||
error_on_warnings=False,
|
|
||||||
)
|
|
||||||
|
|
|
@ -849,7 +849,7 @@ def test_create_archive_with_stats_calls_borg_with_stats_parameter():
|
||||||
flexmock(module).should_receive('_make_exclude_flags').and_return(())
|
flexmock(module).should_receive('_make_exclude_flags').and_return(())
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
flexmock(module).should_receive('execute_command').with_args(
|
||||||
('borg', 'create', '--stats') + ARCHIVE_WITH_PATHS,
|
('borg', 'create', '--stats') + ARCHIVE_WITH_PATHS,
|
||||||
output_log_level=logging.WARNING,
|
output_log_level=logging.INFO,
|
||||||
error_on_warnings=False,
|
error_on_warnings=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ def test_prune_archives_with_log_debug_calls_borg_with_debug_parameter():
|
||||||
BASE_PRUNE_FLAGS
|
BASE_PRUNE_FLAGS
|
||||||
)
|
)
|
||||||
insert_execute_command_mock(
|
insert_execute_command_mock(
|
||||||
PRUNE_COMMAND + ('--stats', '--debug', '--list', '--show-rc', 'repo'), logging.INFO
|
PRUNE_COMMAND + ('--stats', '--list', '--debug', '--show-rc', 'repo'), logging.INFO
|
||||||
)
|
)
|
||||||
insert_logging_mock(logging.DEBUG)
|
insert_logging_mock(logging.DEBUG)
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ def test_prune_archives_with_stats_calls_borg_with_stats_parameter():
|
||||||
flexmock(module).should_receive('_make_prune_flags').with_args(retention_config).and_return(
|
flexmock(module).should_receive('_make_prune_flags').with_args(retention_config).and_return(
|
||||||
BASE_PRUNE_FLAGS
|
BASE_PRUNE_FLAGS
|
||||||
)
|
)
|
||||||
insert_execute_command_mock(PRUNE_COMMAND + ('--stats', 'repo'), logging.WARNING)
|
insert_execute_command_mock(PRUNE_COMMAND + ('--stats', 'repo'), logging.INFO)
|
||||||
|
|
||||||
module.prune_archives(
|
module.prune_archives(
|
||||||
dry_run=False,
|
dry_run=False,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user
Potential simplification: You can probably remove the
if logger.isEnabledFor(logging.INFO)
check, given that Borg's--list --filter
works at verbosity 0, and it's now opt-in. Example revision:Agree, will change as suggested.