[Kimchi-devel] [PATCH] [Wok] Bugfix 30: Duplicated log messages

Jose Ricardo Ziviani joserz at linux.vnet.ibm.com
Mon Feb 15 19:51:34 UTC 2016


 - today we have two file handlers pointing to the same file, this
   commit closes the standard file handler to use the watched
   file handler.

Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
---
 src/wok/server.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/wok/server.py b/src/wok/server.py
index 80c1da2..13851e8 100644
--- a/src/wok/server.py
+++ b/src/wok/server.py
@@ -101,6 +101,17 @@ class Server(object):
         if dev_env:
             cherrypy.log.screen = True
 
+        # close standard file handlers because we are going to use a
+        # watchedfiled handler, otherwise we will have two file handlers
+        # pointing to the same file, duplicating log enries
+        for handler in cherrypy.log.access_log.handlers[:]:
+            if isinstance(handler, logging.FileHandler):
+                cherrypy.log.access_log.removeHandler(handler)
+
+        for handler in cherrypy.log.error_log.handlers[:]:
+            if isinstance(handler, logging.FileHandler):
+                cherrypy.log.error_log.removeHandler(handler)
+
         # Create handler to access log file
         h = logging.handlers.WatchedFileHandler(options.access_log, 'a',
                                                 delay=1)
-- 
1.9.1




More information about the Kimchi-devel mailing list