[Zope3-checkins] CVS: Zope3/lib/python/Zope/Server - ZLogIntegration.py:1.4

Guido van Rossum guido@python.org
Fri, 20 Dec 2002 17:30:30 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Server
In directory cvs.zope.org:/tmp/cvs-serv2349/Server

Added Files:
	ZLogIntegration.py 
Log Message:
Put back ZLogIntegration.py, converted to the logging module.
(I didn't bother to fix the name. :-)


=== Zope3/lib/python/Zope/Server/ZLogIntegration.py 1.3 => 1.4 ===
--- /dev/null	Fri Dec 20 17:30:30 2002
+++ Zope3/lib/python/Zope/Server/ZLogIntegration.py	Fri Dec 20 17:30:29 2002
@@ -0,0 +1,36 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Make asyncore log to the logging module.
+
+As a side effect of importing this module, asyncore's logging will be
+redirected to the logging module.
+
+$Id$
+"""
+
+import logging
+
+logger = logging.getLogger("Zope.Server")
+
+severity = {
+    'info': logging.INFO,
+    'warning': logging.WARN,
+    'error': logging.ERROR,
+    }
+
+def log_info(self, message, type='info'):
+    logger.log(severity.get(type, logging.INFO), message)
+
+import asyncore
+asyncore.dispatcher.log_info = log_info