From 98759887a383287a074faf15436a819c986eca03 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Mon, 5 Nov 2018 10:28:06 +0100 Subject: [plugins] Decrease log verbosity when do_file_sub failed on missing file In case do_file_sub fails to apply a substitution on a non-existing file, don't log it as an error log to stdout. Resolves: #1471 Signed-off-by: Pavel Moravec --- sos/plugins/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index d8582670..2e30d86b 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -354,8 +354,14 @@ class Plugin(object): else: replacements = 0 except Exception as e: - msg = "regex substitution failed for '%s' with: '%s'" - self._log_error(msg % (path, e)) + # if trying to regexp a nonexisting file, dont log it as an + # error to stdout + if e.errno == errno.ENOENT: + msg = "file '%s' not collected, substitution skipped" + self._log_debug(msg % path) + else: + msg = "regex substitution failed for '%s' with: '%s'" + self._log_error(msg % (path, e)) replacements = 0 return replacements -- cgit