[Zodb-checkins] CVS: Zope/lib/python/zLOG - MinimalLogger.py:1.21 __init__.py:1.12

Fred L. Drake, Jr. fred@zope.com
Fri, 22 Nov 2002 13:17:40 -0500


Update of /cvs-repository/Zope/lib/python/zLOG
In directory cvs.zope.org:/tmp/cvs-serv30903

Modified Files:
	MinimalLogger.py __init__.py 
Log Message:
Revert zLOG changes that proved to be contentious.

=== Zope/lib/python/zLOG/MinimalLogger.py 1.20 => 1.21 ===
--- Zope/lib/python/zLOG/MinimalLogger.py:1.20	Thu Nov 21 18:17:57 2002
+++ Zope/lib/python/zLOG/MinimalLogger.py	Fri Nov 22 13:17:39 2002
@@ -14,7 +14,6 @@
 __version__='$Revision$'[11:-2]
 
 import os, sys, time
-import zLOG
 
 try:
     import textwrap
@@ -54,39 +53,7 @@
         self.initialize()
 
     def initialize(self):
-        path, severity = self.get_environment_info()
-        self.initialize_log(path, severity)
-
-    def initialize_with_config(self, config):
-        """Initialize logging with information from ZConfig."""
-        path, severity = self.get_environment_info()
-
-        if config is not None:
-            loginfo = config.getSection("log")
-            if loginfo is not None:
-                if path is None:
-                    path = loginfo.get("path")
-                if severity is None:
-                    severity = loginfo.get("level")
-
-        self.initialize_log(path, severity)
-
-    def initialize_log(self, path, severity):
         global _log_level
-
-        if path is None:
-            _set_log_dest(None)
-        elif path:
-            _set_log_dest(open(path, 'a'))
-        else:
-            _set_log_dest(sys.stderr)
-
-        if severity:
-            _log_level = zLOG.severity(severity)
-        else:
-            _log_level = 0 # INFO
-
-    def get_environment_info(self):
         eget = os.environ.get
 
         # EVENT_LOG_FILE is the preferred envvar, but we accept
@@ -94,14 +61,21 @@
         path = eget('EVENT_LOG_FILE')
         if path is None:
             path = eget('STUPID_LOG_FILE')
+        if path is None:
+            _set_log_dest(None)
+        else:
+            if path:
+                _set_log_dest(open(path, 'a'))
+            else:
+                _set_log_dest(sys.stderr)
 
         # EVENT_LOG_SEVERITY is the preferred envvar, but we accept
         # STUPID_LOG_SEVERITY also
-        severity = eget('EVENT_LOG_SEVERITY')
-        if severity is None:
-            severity = eget('STUPID_LOG_SEVERITY')
-
-        return path, severity
+        severity = eget('EVENT_LOG_SEVERITY') or eget('STUPID_LOG_SEVERITY')
+        if severity:
+            _log_level = int(severity)
+        else:
+            _log_level = 0 # INFO
 
     def log(self, subsystem, severity, summary, detail, error):
         if _log_dest is None or severity < _log_level:
@@ -138,4 +112,3 @@
 _log = stupid_log_write()
 log_write = _log.log
 initialize = _log.initialize
-initialize_with_config = _log.initialize_with_config


=== Zope/lib/python/zLOG/__init__.py 1.11 => 1.12 ===
--- Zope/lib/python/zLOG/__init__.py:1.11	Thu Nov 21 18:17:57 2002
+++ Zope/lib/python/zLOG/__init__.py	Fri Nov 22 13:17:39 2002
@@ -89,7 +89,7 @@
 __version__='$Revision$'[11:-2]
 
 from MinimalLogger import log_write, log_time, severity_string, \
-     _set_log_dest, initialize, initialize_with_config
+     _set_log_dest, initialize
 from traceback import format_exception
 
 # Standard severities
@@ -101,30 +101,6 @@
 WARNING =  100
 ERROR   =  200
 PANIC   =  300
-
-_severity_names = {"trace":   -300,
-                   "debug":   -200,
-                   "blather": -100,
-                   "info":       0,
-                   "problem":  100,
-                   "warning":  100,
-                   "error":    200,
-                   "panic":    300,
-                   }
-
-def severity(value):
-    """Return the severity level associated with a value.
-
-    The value may be an integer, the repr of an integer, or the name
-    of a well-known severity value (case-insensitive).
-    """
-    try:
-        return int(value)
-    except ValueError:
-        try:
-            return _severity_names[value.lower()]
-        except KeyError:
-            raise ValueError("unknown severity value: " + repr(value))
 
 def LOG(subsystem, severity, summary, detail='', error=None, reraise=None):
     """Log some information