[Mpuls-commits] r5781 - in base/trunk: . mpulsweb/lib mpulsweb.egg-info

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jan 20 13:59:35 CET 2012


Author: ludwig
Date: 2012-01-20 13:59:34 +0100 (Fri, 20 Jan 2012)
New Revision: 5781

Modified:
   base/trunk/development.ini
   base/trunk/mpulsweb.egg-info/paste_deploy_config.ini_tmpl
   base/trunk/mpulsweb/lib/logfilter.py
Log:
Change filtered_handler into FilteredHandler class.

Now if you want mpuls_dbname in the log output, use the FilteredHandler.


Modified: base/trunk/development.ini
===================================================================
--- base/trunk/development.ini	2012-01-20 11:15:18 UTC (rev 5780)
+++ base/trunk/development.ini	2012-01-20 12:59:34 UTC (rev 5781)
@@ -131,13 +131,13 @@
 qualname = mpulsweb
 
 [handler_console]
-class = mpulsweb.lib.logfilter.filtered_handler
+class = mpulsweb.lib.logfilter.FilteredHandler
 args = (StreamHandler, sys.stderr)
 level = NOTSET
 formatter = generic
 
 [handler_file]
-class = mpulsweb.lib.logfilter.filtered_handler
+class = mpulsweb.lib.logfilter.FilteredHandler
 # Third parameter in args is maximum size of the log file in bytes.
 # Fourth parameter specifies the number of old files to keep.
 args = (logging.handlers.RotatingFileHandler, 'mpuls.log', 'w', 1048576, 5)

Modified: base/trunk/mpulsweb/lib/logfilter.py
===================================================================
--- base/trunk/mpulsweb/lib/logfilter.py	2012-01-20 11:15:18 UTC (rev 5780)
+++ base/trunk/mpulsweb/lib/logfilter.py	2012-01-20 12:59:34 UTC (rev 5781)
@@ -49,7 +49,17 @@
         return True
 
 
-def filtered_handler(base_handler, *args):
-    handler = base_handler(*args)
-    handler.addFilter(DBNameContextFilter())
-    return handler
+class FilteredHandler(object):
+
+    """Creation of this class returns the base_handler with a 
+    DBNameContextFilter.
+
+    In Python 2.6 a handler object needs to be a class.
+    Overwritting __new__ is a way to add the filter and return the
+    base_handler.
+    """
+
+    def __new__(cls, base_handler, *args):
+        handler = base_handler(*args)
+        handler.addFilter(DBNameContextFilter())
+        return handler

Modified: base/trunk/mpulsweb.egg-info/paste_deploy_config.ini_tmpl
===================================================================
--- base/trunk/mpulsweb.egg-info/paste_deploy_config.ini_tmpl	2012-01-20 11:15:18 UTC (rev 5780)
+++ base/trunk/mpulsweb.egg-info/paste_deploy_config.ini_tmpl	2012-01-20 12:59:34 UTC (rev 5781)
@@ -119,7 +119,7 @@
 qualname = %(mpuls.app.instance)s
 
 [handler_console]
-class = mpulsweb.lib.logfilter.filtered_handler
+class = mpulsweb.lib.logfilter.FilteredHandler
 args = (StreamHandler, sys.stderr)
 level = NOTSET
 formatter = generic
@@ -131,7 +131,7 @@
 formatter = message
 
 [handler_file]
-class = mpulsweb.lib.logfilter.filtered_handler
+class = mpulsweb.lib.logfilter.FilteredHandler
 # Third parameter in args is maximum size of the log file in bytes.
 # Fourth parameter specifies the number of old files to keep.
 args=(logging.handlers.RotatingFileHandler,'mpuls.log', 'w', 1048576, 5)



More information about the Mpuls-commits mailing list