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

source_changes at macosforge.org source_changes at macosforge.org
Wed May 22 17:36:49 PDT 2013


Revision: 11237
          http://trac.calendarserver.org//changeset/11237
Author:   wsanchez at apple.com
Date:     2013-05-22 17:36:49 -0700 (Wed, 22 May 2013)
Log Message:
-----------
Cosmetic, spacing to code standard.

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

Modified: CalendarServer/trunk/twext/python/log.py
===================================================================
--- CalendarServer/trunk/twext/python/log.py	2013-05-22 23:40:30 UTC (rev 11236)
+++ CalendarServer/trunk/twext/python/log.py	2013-05-23 00:36:49 UTC (rev 11237)
@@ -33,15 +33,15 @@
         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.
+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 instantiated it, or, in
+the case of a class using 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}.
+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__ = [
@@ -68,6 +68,8 @@
 from twisted.python.log import msg as twistedLogMessage
 from twisted.python.log import addObserver, removeObserver
 
+
+
 logLevels = (
     "debug",
     "info",
@@ -75,8 +77,10 @@
     "error",
 )
 
+
 logLevelIndexes = dict(zip(logLevels, xrange(0, len(logLevels))))
 
+
 def cmpLogLevels(a, b):
     """
     Compare two log levels.
@@ -87,10 +91,11 @@
     """
     return cmp(logLevelIndexes[a], logLevelIndexes[b])
 
-##
+
+
+#
 # Mappings to Python's logging module
-##
-
+#
 pythonLogLevelMapping = {
     "debug"   : logging.DEBUG,
     "info"    : logging.INFO,
@@ -99,6 +104,7 @@
    #"critical": logging.CRITICAL,
 }
 
+
 def pythonLogLevelForLevel(level):
     """
     @param: a log level
@@ -119,6 +125,8 @@
 #
 #    return logging.CRITICAL
 
+
+
 ##
 # Tools for managing log levels
 ##
@@ -146,6 +154,7 @@
 
     return logLevelsByNamespace[None]
 
+
 def setLogLevelForNamespace(namespace, level):
     """
     Sets the log level for a logging namespace.
@@ -160,6 +169,7 @@
     else:
         logLevelsByNamespace[None] = level
 
+
 def clearLogLevels():
     """
     Clears all log levels to the default.
@@ -167,9 +177,12 @@
     logLevelsByNamespace.clear()
     logLevelsByNamespace[None] = "warn"  # Default log level
 
+
 logLevelsByNamespace = {}
 clearLogLevels()
 
+
+
 ##
 # Loggers
 ##
@@ -194,9 +207,11 @@
 
         self.namespace = namespace
 
+
     def __repr__(self):
         return "<%s %r>" % (self.__class__.__name__, self.namespace)
 
+
     def emit(self, level, message=None, **kwargs):
         """
         Called internally to emit log messages at a given log level.
@@ -232,12 +247,14 @@
 
         twistedLogMessage(**kwargs)
 
+
     def level(self):
         """
         @return: the logging level for this logger's namespace.
         """
         return logLevelForNamespace(self.namespace)
 
+
     def setLevel(self, level):
         """
         Set the logging level for this logger's namespace.
@@ -245,6 +262,7 @@
         """
         setLogLevelForNamespace(self.namespace, level)
 
+
     def willLogAtLevel(self, level):
         """
         @param level: a logging level
@@ -296,12 +314,14 @@
 
         return self._logger
 
+
     def _setLogger(self, value):
         self._logger = value
 
     logger = property(_getLogger, _setLogger)
 
 
+
 def bindEmit(level):
     doc = """
     Emit a log message at log level C{%s}.
@@ -357,6 +377,7 @@
         self.level = level
 
 
+
 ##
 # Observers
 ##
@@ -381,8 +402,10 @@
         output.write(text)
         output.flush()
 
+
     def start(self):
         addObserver(self.emit)
 
+
     def stop(self):
         removeObserver(self.emit)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130522/c90cea37/attachment.html>


More information about the calendarserver-changes mailing list