[CalendarServer-changes] [2354] CalendarServer/branches/users/wsanchez/logging/twistedcaldav/log.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 25 19:04:21 PDT 2008


Revision: 2354
          http://trac.macosforge.org/projects/calendarserver/changeset/2354
Author:   wsanchez at apple.com
Date:     2008-04-25 19:04:20 -0700 (Fri, 25 Apr 2008)

Log Message:
-----------
log_level -> log_emit
Docstrings.

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/logging/twistedcaldav/log.py

Modified: CalendarServer/branches/users/wsanchez/logging/twistedcaldav/log.py
===================================================================
--- CalendarServer/branches/users/wsanchez/logging/twistedcaldav/log.py	2008-04-26 00:33:28 UTC (rev 2353)
+++ CalendarServer/branches/users/wsanchez/logging/twistedcaldav/log.py	2008-04-26 02:04:20 UTC (rev 2354)
@@ -31,6 +31,16 @@
     class Foo (LoggingMixIn):
         def oops(self):
             self.log_error("Oops!")
+
+C{Logger}s have namespaces, for which logging can be configured
+independently.  Namespaces may be specified by passing in a
+C{namespace} argument to L{Logger} when instantiating it, but if none
+is given, the logger will derive its own namespace by using the module
+name of the callable that instantiating it, or, in the case of a
+L{LoggingMixIn}, by using the fully qualified name of the class.
+
+In the first example above, the namespace would be C{some.module}, and
+in the second example, it would be C{some.module.Foo}.
 """
 
 __all__ = [
@@ -77,7 +87,8 @@
 
 def logLevelForNamespace(namespace):
     """
-    @param namespace: a logging namespace
+    @param namespace: a logging namespace, or C{None} to set the
+        default log level.
     @return: the log level for the given namespace.
     """
     if not namespace:
@@ -187,24 +198,24 @@
     #
     # Attach methods to Logger
     #
-    def log_level(self, message, level=level, **kwargs):
+    def log_emit(self, message, level=level, **kwargs):
         self.emit(level, message, **kwargs)
 
-    log_level.__doc__ = doc
+    log_emit.__doc__ = doc
 
-    setattr(Logger, level, log_level)
+    setattr(Logger, level, log_emit)
 
     #
     # Attach methods to LoggingMixIn
     #
-    def log_level(self, message, level=level, **kwargs):
+    def log_emit(self, message, level=level, **kwargs):
         self.logger.emit(level, message, **kwargs)
 
-    log_level.__doc__ = doc
+    log_emit.__doc__ = doc
 
-    setattr(LoggingMixIn, "log_%s" % (level,), log_level)
+    setattr(LoggingMixIn, "log_%s" % (level,), log_emit)
 
-del level, log_level
+del level, log_emit
 
 # Add some compatibility with twisted's log module
 Logger.msg = Logger.info

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080425/88bee40c/attachment.html


More information about the calendarserver-changes mailing list