[Zodb-checkins] CVS: ZODB4/zdaemon - zdaemon.py:1.26

Jeremy Hylton jeremy@zope.com
Fri, 20 Dec 2002 13:49:31 -0500


Update of /cvs-repository/ZODB4/zdaemon
In directory cvs.zope.org:/tmp/cvs-serv5547

Modified Files:
	zdaemon.py 
Log Message:
Replace zLOG with logging


=== ZODB4/zdaemon/zdaemon.py 1.25 => 1.26 ===
--- ZODB4/zdaemon/zdaemon.py:1.25	Mon Nov 25 14:47:48 2002
+++ ZODB4/zdaemon/zdaemon.py	Fri Dec 20 13:49:30 2002
@@ -78,6 +78,7 @@
 
 """
 
+import logging
 import os
 import sys
 import time
@@ -93,8 +94,6 @@
     from os.path import dirname, abspath, normpath
     sys.path.append(dirname(dirname(normpath(abspath(sys.argv[0])))))
 
-import zLOG
-
 class Options:
 
     """A class to parse and hold the command line options.
@@ -713,35 +712,14 @@
             warn("Error sending reply: %s" % str(msg))
 
 # Log messages with various severities.
-# This uses zLOG, but the API is a simplified version of PEP 282
 
-def critical(msg):
-    """Log a critical message."""
-    _log(msg, zLOG.PANIC)
-
-def error(msg):
-    """Log an error message."""
-    _log(msg, zLOG.ERROR)
-
-def exception(msg):
-    """Log an exception (an error message with a traceback attached)."""
-    _log(msg, zLOG.ERROR, error=sys.exc_info())
-
-def warn(msg):
-    """Log a warning message."""
-    _log(msg, zLOG.PROBLEM)
-
-def info(msg):
-    """Log an informational message."""
-    _log(msg, zLOG.INFO)
-
-def debug(msg):
-    """Log a debugging message."""
-    _log(msg, zLOG.DEBUG)
-
-def _log(msg, severity=zLOG.INFO, error=None):
-    """Internal: generic logging function."""
-    zLOG.LOG("ZD:%d" % os.getpid(), severity, msg, "", error)
+logger = logging.getLogger("ZD:%d" % os.getpid())
+critical = logger.critical
+error = logger.error
+exception = logger.exception
+warn = logger.warn
+info = logger.info
+debug = logger.debug
 
 # Helpers for dealing with signals and exit status
 
@@ -808,7 +786,12 @@
 
 def main(args=None):
     assert os.name == "posix", "This code makes many Unix-specific assumptions"
-    zLOG.initialize()
+
+    # Initialize the logging module.
+    import logging.config
+    logging.basicConfig()
+    logging.root.setLevel(logging.CRITICAL)
+
     d = Daemonizer()
     d.main(args)