summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfmenguy <francoisregis.menguy@orange.com>2021-03-02 15:24:29 +0100
committerfmenguy <francoisregis.menguy@orange.com>2021-03-03 16:26:04 +0100
commitb2b88e448a0415b263b4e063471860ac23cafe3e (patch)
tree4cba11dafb412c9703f825396574b14b995eda21
parent20eb2fab49af9fe4a108728818c495975f0d2a0e (diff)
NFVBENCH-198 Error in File logger management (REST API)
Change-Id: I9c798b3bcbf416c0d3f107856aca0872c650a580 Signed-off-by: fmenguy <francoisregis.menguy@orange.com>
-rw-r--r--nfvbench/nfvbench.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/nfvbench/nfvbench.py b/nfvbench/nfvbench.py
index 427c94c..6373a59 100644
--- a/nfvbench/nfvbench.py
+++ b/nfvbench/nfvbench.py
@@ -185,13 +185,14 @@ class NFVBench(object):
'will be created.', path)
os.makedirs(path)
LOG.info('%s is created.', path)
- for h in log.getLogger().handlers:
- if isinstance(h, FileHandler) and h.baseFilename != opts['log_file']:
- # clean log file handler
- log.getLogger().removeHandler(h)
- # add handler if not existing to avoid duplicates handlers
- if len(log.getLogger().handlers) == 1:
+ if not any(isinstance(h, FileHandler) for h in log.getLogger().handlers):
log.add_file_logger(opts['log_file'])
+ else:
+ for h in log.getLogger().handlers:
+ if isinstance(h, FileHandler) and h.baseFilename != opts['log_file']:
+ # clean log file handler
+ log.getLogger().removeHandler(h)
+ log.add_file_logger(opts['log_file'])
self.config.update(opts)
config = self.config