From 4adc782100437a2af689ea1ab60d11f774a54f77 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 18 Nov 2023 22:37:38 +0100 Subject: [PATCH] print_warning*: support warning msgids, fixes #7080 --- src/borg/archiver/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/borg/archiver/__init__.py b/src/borg/archiver/__init__.py index 3aba28a79..20abf5ef2 100644 --- a/src/borg/archiver/__init__.py +++ b/src/borg/archiver/__init__.py @@ -133,19 +133,21 @@ class Archiver( warning_code = kw.get("wc", EXIT_WARNING) # note: wc=None can be used to not influence exit code warning_type = kw.get("wt", "percent") assert warning_type in ("percent", "curly") + warning_msgid = kw.get("msgid") if warning_code is not None: add_warning(msg, *args, wc=warning_code, wt=warning_type) if warning_type == "percent": output = args and msg % args or msg else: # == "curly" output = args and msg.format(*args) or msg - logger.warning(output) + logger.warning(output, msgid=warning_msgid) if warning_msgid else logger.warning(output) def print_warning_instance(self, warning): assert isinstance(warning, BorgWarning) msg = type(warning).__doc__ + msgid = type(warning).__qualname__ args = warning.args - self.print_warning(msg, *args, wc=warning.exit_code, wt="curly") + self.print_warning(msg, *args, wc=warning.exit_code, wt="curly", msgid=msgid) def print_file_status(self, status, path): # if we get called with status == None, the final file status was already printed