Commit 82bce9ba authored by Fred Drake's avatar Fred Drake

add BaseLogger to ZServer, since this is now the only place it is used

parent 9764267f
......@@ -16,13 +16,17 @@ A logging module which handles ZServer access log messages.
This depends on Vinay Sajip's PEP 282 logging module.
"""
import logging
from zLOG.BaseLogger import BaseLogger
from ZServer.BaseLogger import BaseLogger
class AccessLogger(BaseLogger):
logger = logging.getLogger('access')
def __init__(self):
BaseLogger.__init__(self, 'access')
def log(self, message):
if not self.logger.handlers: # dont log if we have no handlers
if not self.logger.handlers: # don't log if we have no handlers
return
if message.endswith('\n'):
message = message[:-1]
......
##############################################################################
#
# 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
#
##############################################################################
"""
An abstract logger meant to provide features to the access logger,
the event logger, and the debug logger.
"""
import logging
class BaseLogger:
def __init__(self, name):
self.logger = logging.getLogger(name)
self.logger.propagate = False
def reopen(self):
for handler in self.logger.handlers:
if hasattr(handler, 'reopen') and callable(handler.reopen):
handler.reopen()
......@@ -36,12 +36,13 @@ where:
import time
import logging
from zLOG.BaseLogger import BaseLogger
from ZServer.BaseLogger import BaseLogger
class DebugLogger(BaseLogger):
logger = logging.getLogger('trace')
def __init__(self):
BaseLogger.__init__(self, 'trace')
def log(self, code, request_id, data=''):
if not self.logger.handlers:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment