aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2017-03-27 13:26:21 +0100
committerBryn M. Reeves <bmr@redhat.com>2017-03-27 13:26:21 +0100
commitc20c93e0375ff242512017ca9b2c2903773ada7d (patch)
tree00ba5806e6c695eda2ace5d4c8b77cb28bc05402
parent3a0e2c3a9c2d5a76fc427dcff83aeff4b38b36e0 (diff)
downloadsos-c20c93e0375ff242512017ca9b2c2903773ada7d.tar.gz
[sosreport] convert sos.log and ui.log to StreamHandler
Use a StreamHandler for sos.log and ui.log so that data is sent directly to the log files, and to avoid the FileHandler creating a bogus '<fdopen>' directory entry. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 8f9b3f18..c4ec7ff9 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -846,8 +846,7 @@ class SoSReport(object):
self.soslog = logging.getLogger('sos')
self.soslog.setLevel(logging.DEBUG)
self.sos_log_file = self.get_temp_file()
- self.sos_log_file.close()
- flog = logging.FileHandler(self.sos_log_file.name)
+ flog = logging.StreamHandler(self.sos_log_file)
flog.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)s: %(message)s'))
flog.setLevel(logging.INFO)
@@ -870,8 +869,7 @@ class SoSReport(object):
self.ui_log = logging.getLogger('sos_ui')
self.ui_log.setLevel(logging.INFO)
self.sos_ui_log_file = self.get_temp_file()
- self.sos_ui_log_file.close()
- ui_fhandler = logging.FileHandler(self.sos_ui_log_file.name)
+ ui_fhandler = logging.StreamHandler(self.sos_ui_log_file)
ui_fhandler.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)s: %(message)s'))
@@ -889,10 +887,10 @@ class SoSReport(object):
# 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,
+ self.archive.add_file(self.sos_log_file,
dest=os.path.join('sos_logs', 'sos.log'))
if getattr(self, "sos_ui_log_file", None):
- self.archive.add_file(self.sos_ui_log_file.name,
+ self.archive.add_file(self.sos_ui_log_file,
dest=os.path.join('sos_logs', 'ui.log'))
def _get_disabled_plugins(self):