[Zope-Checkins] CVS: Zope/lib/python/ZServer - AccessLogger.py:1.1.2.1

Fred L. Drake, Jr. fred@zope.com
Thu, 30 Jan 2003 11:38:44 -0500


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

Added Files:
      Tag: new-install-branch
	AccessLogger.py 
Log Message:
Add the AccessLogger from the chrism-install-branch, but in a new location.

=== Added File Zope/lib/python/ZServer/AccessLogger.py ===
##############################################################################
#
# Copyright (c) 2001, 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
#
##############################################################################
"""
A logging module which handles ZServer access log messages.

This depends on Vinay Sajip's PEP 282 logging module.
"""
import logging
from BaseLogger import BaseLogger

class AccessLogger(BaseLogger):
    logger = logging.getLogger('access')
    def log(self, message):
        if not self.logger.handlers: # dont log if we have no handlers
            return
        if message.endswith('\n'):
            message = message[:-1]
        self.logger.warn(message)

access_logger = AccessLogger()