aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-09-13 11:56:21 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-09-13 11:56:21 +0100
commitdcbfb39e1cfea0cfbdcf736de01f2e33dd674e8d (patch)
tree4a38ce0afd26f8897718da6ecde7d1fad8801a39
parent7c7707115a54e6be692f8c678fa5378982875509 (diff)
downloadsos-dcbfb39e1cfea0cfbdcf736de01f2e33dd674e8d.tar.gz
[sosreport] re-order logging shutdown
Currently we remove all log handlers and then add the log files to the archive. This can cause messages to leak to the console when running in --quiet mode: # sosreport -o lvm2 --batch --build --debug --quiet No handlers could be found for logger "sos" This happens because the Archive classes output to the 'sos' logger; removing the handlers before archiving the logs causes a default basicConfig to be used and generates the above message. Add the files to the archive and then remove the handlers. Fixes #393. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index c0813b8f..34b45ab2 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -729,12 +729,10 @@ class SoSReport(object):
def _finish_logging(self):
logging.shutdown()
- # the logging module seems to persist in the jython/jboss/eap world
- # so the handlers need to be removed
- for logger in [logging.getLogger(x) for x in ('sos', 'sos_ui')]:
- for h in logger.handlers:
- logger.removeHandler(h)
-
+ # Make sure the log files are added before we remove the log
+ # handlers. This prevents "No handlers could be found.." messages
+ # from leaking to the console when running in --quiet mode when
+ # Archive classes attempt to acess the log API.
if getattr(self, "sos_log_file", None):
self.archive.add_file(self.sos_log_file.name,
dest=os.path.join('sos_logs', 'sos.log'))
@@ -742,6 +740,12 @@ class SoSReport(object):
self.archive.add_file(self.sos_ui_log_file.name,
dest=os.path.join('sos_logs', 'ui.log'))
+ # the logging module seems to persist in the jython/jboss/eap world
+ # so the handlers need to be removed
+ for logger in [logging.getLogger(x) for x in ('sos', 'sos_ui')]:
+ for h in logger.handlers:
+ logger.removeHandler(h)
+
def _get_disabled_plugins(self):
disabled = []
if self.config.has_option("plugins", "disable"):