[CalendarServer-changes] [11534] CalendarServer/trunk/twext/python/log.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Jul 18 11:56:59 PDT 2013


Revision: 11534
          http://trac.calendarserver.org//changeset/11534
Author:   glyph at apple.com
Date:     2013-07-18 11:56:59 -0700 (Thu, 18 Jul 2013)
Log Message:
-----------
Fix log level ordering.

Modified Paths:
--------------
    CalendarServer/trunk/twext/python/log.py

Modified: CalendarServer/trunk/twext/python/log.py
===================================================================
--- CalendarServer/trunk/twext/python/log.py	2013-07-18 16:56:59 UTC (rev 11533)
+++ CalendarServer/trunk/twext/python/log.py	2013-07-18 18:56:59 UTC (rev 11534)
@@ -139,6 +139,22 @@
             raise InvalidLogLevelError(name)
 
 
+    @classmethod
+    def _priorityForLevel(cls, constant):
+        """
+        We want log levels to have defined ordering - the order of definition -
+        but they aren't value constants (the only value is the name).  This is
+        arguably a bug in Twisted, so this is just a workaround for U{until
+        this is fixed in some way
+        <https://twistedmatrix.com/trac/ticket/6523>}.
+        """
+        return cls._levelPriorities[constant]
+
+LogLevel._levelPriorities = dict((constant, idx)
+                                 for (idx, constant) in
+                                     (enumerate(LogLevel.iterconstants())))
+
+
 #
 # Mappings to Python's logging module
 #
@@ -686,7 +702,8 @@
         level     = event["log_level"]
         namespace = event["log_namespace"]
 
-        if level < self.logLevelForNamespace(namespace):
+        if (LogLevel._priorityForLevel(level) <
+            LogLevel._priorityForLevel(self.logLevelForNamespace(namespace))):
             return PredicateResult.no
 
         return PredicateResult.maybe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130718/484c8e9d/attachment.html>


More information about the calendarserver-changes mailing list