diff --git a/borgmatic/borg/list.py b/borgmatic/borg/list.py index d995f262..757083f6 100644 --- a/borgmatic/borg/list.py +++ b/borgmatic/borg/list.py @@ -237,7 +237,7 @@ def list_archive( # For each archive listed by Borg, run list on the contents of that archive. for archive in archive_lines: - logger.answer(f'{repository_path}: Listing archive {archive}') + logger.answer(f'Listing archive {archive}') archive_arguments = copy.copy(list_arguments) archive_arguments.archive = archive diff --git a/borgmatic/borg/repo_list.py b/borgmatic/borg/repo_list.py index fbc3b7b9..cfe914d4 100644 --- a/borgmatic/borg/repo_list.py +++ b/borgmatic/borg/repo_list.py @@ -59,7 +59,7 @@ def resolve_archive_name( except IndexError: raise ValueError('No archives found in the repository') - logger.debug(f'{repository_path}: Latest archive is {latest_archive}') + logger.debug(f'Latest archive is {latest_archive}') return latest_archive diff --git a/borgmatic/execute.py b/borgmatic/execute.py index 76442d23..88f55cb3 100644 --- a/borgmatic/execute.py +++ b/borgmatic/execute.py @@ -6,6 +6,8 @@ import select import subprocess import textwrap +import borgmatic.logger + logger = logging.getLogger(__name__) @@ -309,13 +311,18 @@ def execute_command( if not run_to_completion: return process - log_outputs( - (process,), - (input_file, output_file), - output_log_level, - borg_local_path, - borg_exit_codes, - ) + try: + original_log_prefix = borgmatic.logger.get_log_prefix() + borgmatic.logger.set_log_prefix(None) # Log command output without any prefix. + log_outputs( + (process,), + (input_file, output_file), + output_log_level, + borg_local_path, + borg_exit_codes, + ) + finally: + borgmatic.logger.set_log_prefix(original_log_prefix) def execute_command_and_capture_output( diff --git a/borgmatic/logger.py b/borgmatic/logger.py index 2a3cb62c..5ef16259 100644 --- a/borgmatic/logger.py +++ b/borgmatic/logger.py @@ -186,6 +186,20 @@ def add_custom_log_levels(): # pragma: no cover add_logging_level('DISABLED', DISABLED) +def get_log_prefix(): + ''' + Return the log prefix (as set with set_log_prefix()) for the first log handler. If there is no + such prefix, return None. + ''' + for handler in logging.getLogger().handlers: + defaults = handler.formatter._style._defaults + + if not defaults: + return None + + return defaults.get('prefix').rstrip().rstrip(':') + + def set_log_prefix(prefix): ''' Given a prefix string, set it onto the formatter defaults for every logging handler so that it