commit 1b57c60cc7145de266caf814dc8a6e7e77e46ab3
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Oct 10 09:30:33 2014 +0200
Logs: reset logging configuration on init
This patch makes sure that the python logging module is cleared of any
previously set log handlers. Without this we could have our logs appear
twice in a row as was experienced when deprecatin messages were added to
the current release of pyroute2.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/Logs.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Common/Logs.py b/lnst/Common/Logs.py
index 89118c1..233f427 100644
--- a/lnst/Common/Logs.py
+++ b/lnst/Common/Logs.py
@@ -102,6 +102,16 @@ class LoggingCtl:
transmit_handler = None
def __init__(self, debug=False, log_dir=None, log_subdir="",
colours=True):
+ #clear any previously set handlers
+ logger = logging.getLogger('')
+ for i in list(logger.handlers):
+ logger.removeHandler(i)
+ for key, logger in logging.Logger.manager.loggerDict.iteritems():
+ if type(logger) != type(logging.Logger):
+ continue
+ for i in list(logger.handlers):
+ logger.removeHandler(i)
+
self._origin_name = None
if log_dir != None:
Show replies by date