From: Ondrej Lichtner <olichtne(a)redhat.com>
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>
---
lnst/Common/Logs.py | 10 ++++++++++
1 file changed, 10 insertions(+)
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:
--
1.9.3
Show replies by date