|
|
8bcace |
From 169898b47b26734a8cdcb748157f7314f7f8821b Mon Sep 17 00:00:00 2001
|
|
|
8bcace |
From: Erik Bernoth <ebernoth@redhat.com>
|
|
|
8bcace |
Date: Tue, 10 Nov 2020 18:32:40 +0100
|
|
|
8bcace |
Subject: [PATCH] [component] Add log verbosity from presets
|
|
|
8bcace |
|
|
|
8bcace |
Closes: #2289
|
|
|
8bcace |
|
|
|
8bcace |
The main problem this tries to solve was that preset verbosity was
|
|
|
8bcace |
ignored in logging.
|
|
|
8bcace |
|
|
|
8bcace |
With a simple test this could be reproduced:
|
|
|
8bcace |
sudo sh -c "source /path/to/repo/sosreport/venv/bin/activate; \
|
|
|
8bcace |
cd /tmp/foo; sos report --preset sostestpreset; cd -"
|
|
|
8bcace |
|
|
|
8bcace |
The bug is that without a change of code there are no messages from the
|
|
|
8bcace |
plugin `host` (no lines of output start wiht "[plugin:host]").
|
|
|
8bcace |
|
|
|
8bcace |
The problem is that the logging is set in the inherited __init__() method
|
|
|
8bcace |
from Component, but the presets are only handled afterwards in the
|
|
|
8bcace |
Report's __init__().
|
|
|
8bcace |
|
|
|
8bcace |
Since it is good to have logging configured from the beginning, the
|
|
|
8bcace |
only option is to reconfigure it after the preset config is known.
|
|
|
8bcace |
|
|
|
8bcace |
The simplest method is to reinitialize the logging, although maybe not
|
|
|
8bcace |
the most efficient.
|
|
|
8bcace |
|
|
|
8bcace |
Signed-off-by: Erik Bernoth <ebernoth@redhat.com>
|
|
|
8bcace |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
8bcace |
---
|
|
|
8bcace |
sos/report/__init__.py | 6 ++++++
|
|
|
8bcace |
1 file changed, 6 insertions(+)
|
|
|
8bcace |
|
|
|
8bcace |
diff --git a/sos/report/__init__.py b/sos/report/__init__.py
|
|
|
8bcace |
index 2e97010b..c6b0c21c 100644
|
|
|
8bcace |
--- a/sos/report/__init__.py
|
|
|
8bcace |
+++ b/sos/report/__init__.py
|
|
|
8bcace |
@@ -153,6 +153,12 @@ class SoSReport(SoSComponent):
|
|
|
8bcace |
self.opts.merge(self.preset.opts)
|
|
|
8bcace |
# re-apply any cmdline overrides to the preset
|
|
|
8bcace |
self.opts = self.apply_options_from_cmdline(self.opts)
|
|
|
8bcace |
+ if hasattr(self.preset.opts, 'verbosity') and \
|
|
|
8bcace |
+ self.preset.opts.verbosity > 0:
|
|
|
8bcace |
+ print('\nWARNING: It is not recommended to set verbosity via the '
|
|
|
8bcace |
+ 'preset as it might have\nunforseen consequences for your '
|
|
|
8bcace |
+ 'report logs.\n')
|
|
|
8bcace |
+ self._setup_logging()
|
|
|
8bcace |
|
|
|
8bcace |
self._set_directories()
|
|
|
8bcace |
|
|
|
8bcace |
--
|
|
|
8bcace |
2.26.2
|
|
|
8bcace |
|