diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2020-05-12 09:20:58 +0200 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2020-05-12 12:22:47 -0400 |
commit | 141f2517b15f6e92d82bb19fc537681e8e34907f (patch) | |
tree | 3f05cef8526f46100677474f273a14ca114f89a3 | |
parent | 4fe1676eaabb59be87d69a8718546d91d1180b5d (diff) | |
download | sos-141f2517b15f6e92d82bb19fc537681e8e34907f.tar.gz |
[general] set file logging only when initialized
To fix regression in 8a2a765:
Could not initialize 'report':
local variable 'flog' referenced before assignment
Resolves: #2057
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r-- | sos/component.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sos/component.py b/sos/component.py index 6b99986b..ad00e434 100644 --- a/sos/component.py +++ b/sos/component.py @@ -182,6 +182,7 @@ class SoSComponent(): # main soslog self.soslog = logging.getLogger('sos') self.soslog.setLevel(logging.DEBUG) + flog = None if not self.check_listing_options(): self.sos_log_file = self.get_temp_file() flog = logging.StreamHandler(self.sos_log_file) @@ -195,10 +196,12 @@ class SoSComponent(): console.setFormatter(logging.Formatter('%(message)s')) if self.opts.verbosity and self.opts.verbosity > 1: console.setLevel(logging.DEBUG) - flog.setLevel(logging.DEBUG) + if flog: + flog.setLevel(logging.DEBUG) elif self.opts.verbosity and self.opts.verbosity > 0: console.setLevel(logging.INFO) - flog.setLevel(logging.DEBUG) + if flog: + flog.setLevel(logging.DEBUG) else: console.setLevel(logging.WARNING) self.soslog.addHandler(console) |