[#2850] Fix duplicate ui log entries

This commit is contained in:
Calum Lind 2016-10-25 21:08:54 +01:00
parent a5bc73f0b3
commit 16da4d851e
1 changed files with 8 additions and 1 deletions

View File

@ -151,7 +151,14 @@ def setup_logger(level="error", filename=None, filemode="w", logrotate=None, twi
) )
handler.setFormatter(formatter) handler.setFormatter(formatter)
root_logger.addHandler(handler)
# Check for existing handler to prevent duplicate logging.
if root_logger.handlers:
for handle in root_logger.handlers:
if not isinstance(handle, type(handler)):
root_logger.addHandler(handler)
else:
root_logger.addHandler(handler)
root_logger.setLevel(level) root_logger.setLevel(level)
if twisted_observer: if twisted_observer: