Change-Id: I9c798b3bcbf416c0d3f107856aca0872c650a580
Signed-off-by: fmenguy <francoisregis.menguy@orange.com>
'will be created.', path)
os.makedirs(path)
LOG.info('%s is created.', path)
'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'])
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
self.config.update(opts)
config = self.config