[Zodb-checkins] CVS: ZODB3/zLOG - EventLogger.py:1.7 component.xml:1.7 datatypes.py:1.9

Guido van Rossum guido@python.org
Thu, 23 Jan 2003 14:59:11 -0500


Update of /cvs-repository/ZODB3/zLOG
In directory cvs.zope.org:/tmp/cvs-serv4347/zLOG

Modified Files:
	EventLogger.py component.xml datatypes.py 
Log Message:
Several changes to the zLOG/logging/ZConfig connection:

(1) Change the mapping from zLOG levels to logging levels to use
    custom intermediary levels 15 and 5 for BLATHER and TRACE, rather
    than using a confusing skewed mapping.

(2) In the ZConfig datatype definition for a logging level, added
    'blather' and 'trace' to the level names, added 'warning' as an
    alias for 'warn', change 'all' to mean 1, and add 'notset' to mean
    0.  The semantics of NOTSET are very different than those of 1;
    setting a logger's level to NOTSET searches for a parent logger
    with a nonzero level.  The root of all loggers is initialized with
    WARN as its level, so setting the level to NOTSET effectively sets
    it to WARN rather than to the most inclusive level!

(3) In the schema, change the default level for handlers to notset, so
    they use their logger's level; the default level for the logger is
    set to info, corresponding to the old default for
    STUPID_LOG_SEVERITY.



=== ZODB3/zLOG/EventLogger.py 1.6 => 1.7 ===
--- ZODB3/zLOG/EventLogger.py:1.6	Mon Jan 13 10:17:30 2003
+++ ZODB3/zLOG/EventLogger.py	Thu Jan 23 14:58:36 2003
@@ -25,6 +25,12 @@
 from LogHandlers import FileHandler, NullHandler, SysLogHandler
 from logging import StreamHandler, Formatter
 
+# Custom logging levels
+CUSTOM_BLATHER = 15 # Mapping for zLOG.BLATHER
+CUSTOM_TRACE = 5 # Mapping for zLOG.TRACE
+logging.addLevelName("BLATHER", CUSTOM_BLATHER)
+logging.addLevelName("TRACE", CUSTOM_TRACE)
+
 class EventLogger(BaseLogger):
 
     # Get our logger object:
@@ -82,23 +88,30 @@
 
     zLOG severity                      PEP282 severity
     -------------                      ---------------
-    PANIC (300)                        critical (50)
-    ERROR (200), PROBLEM (100)         error (40)
-    INFO (0)                           warn (30)
-    BLATHER (-100)                     info (20)
-    DEBUG (-200), TRACE (-300)         debug (10)
+    PANIC (300)                        FATAL, CRITICAL (50)
+    ERROR (200)                        ERROR (40)
+    WARNING, PROBLEM (100)             WARN (30)
+    INFO (0)                           INFO (20)
+    BLATHER (-100)                     BLATHER (15) [*]
+    DEBUG (-200)                       DEBUG (10)
+    TRACE (-300)                       TRACE (5) [*]
+
+    [*] BLATHER and TRACE are custom logging levels.
     """
     sev = zlog_severity
     if sev >= 300:
-        return logging.CRITICAL
-    if sev >= 100:
+        return logging.FATAL
+    if sev >= 200:
         return logging.ERROR
-    if sev >= 0:
+    if sev >= 100:
         return logging.WARN
-    if sev >= -100:
+    if sev >= 0:
         return logging.INFO
-    else:
+    if sev >= -100:
+        return CUSTOM_BLATHER
+    if sev >= -200:
         return logging.DEBUG
+    return CUSTOM_TRACE
 
 zlog_to_pep282_severity_cache = {}
 for _sev in range(-300, 301, 100):
@@ -158,7 +171,8 @@
 def initialize_from_environment():
     """ Reinitialize the event logger from the environment """
     # clear the current handlers from the event logger
-    event_logger.logger.handlers = []
+    for h in event_logger.logger.handlers[:]:
+        event_logger.logger.removeHandler(h)
 
     handlers = []
 


=== ZODB3/zLOG/component.xml 1.6 => 1.7 ===
--- ZODB3/zLOG/component.xml:1.6	Thu Jan 23 13:03:05 2003
+++ ZODB3/zLOG/component.xml	Thu Jan 23 14:58:36 2003
@@ -9,7 +9,7 @@
       abstract section type.
     </description>
     <key name="dateformat" default="%Y-%m-%dT%H:%M:%S"/>
-    <key name="level" default="info" datatype=".logging_level"/>
+    <key name="level" default="notset" datatype=".logging_level"/>
   </sectiontype>
 
   <sectiontype name="logfile" datatype=".FileHandlerFactory"
@@ -54,7 +54,7 @@
 
 
   <sectiontype name="eventlog" datatype=".EventLogFactory">
-     <key name="level" datatype=".logging_level" default="all"/>
+     <key name="level" datatype=".logging_level" default="info"/>
      <multisection type="loghandler" attribute="handlers" name="*"/>
   </sectiontype>
 


=== ZODB3/zLOG/datatypes.py 1.8 => 1.9 ===
--- ZODB3/zLOG/datatypes.py:1.8	Thu Jan 23 13:03:05 2003
+++ ZODB3/zLOG/datatypes.py	Thu Jan 23 14:58:36 2003
@@ -25,9 +25,13 @@
     "fatal": 50,
     "error": 40,
     "warn": 30,
+    "warning": 30,
     "info": 20,
+    "blather": 15,
     "debug": 10,
-    "all": 0,
+    "trace": 5,
+    "all": 1,
+    "notset": 0,
     }
 
 def logging_level(value):