[Zodb-checkins] CVS: Zope/lib/python/zLOG - EventLogger.py:1.14
__init__.py:1.19 component.xml:NONE datatypes.py:NONE
Fred L. Drake, Jr.
fred at zope.com
Tue Apr 13 10:29:26 EDT 2004
Update of /cvs-repository/Zope/lib/python/zLOG
In directory cvs.zope.org:/tmp/cvs-serv12793/zLOG
Modified Files:
EventLogger.py __init__.py
Removed Files:
component.xml datatypes.py
Log Message:
Remove all logging configuration from zLOG; the only thing zLOG provides now
is an API shim to the logging module. No more competing initializations!
=== Zope/lib/python/zLOG/EventLogger.py 1.13 => 1.14 ===
--- Zope/lib/python/zLOG/EventLogger.py:1.13 Fri Apr 9 17:21:57 2004
+++ Zope/lib/python/zLOG/EventLogger.py Tue Apr 13 10:28:54 2004
@@ -20,13 +20,8 @@
__version__='$Revision$'[11:-2]
import logging
-import os
import time
-from BaseLogger import BaseLogger
-from ZConfig.components.logger import loghandler
-from logging import StreamHandler, Formatter
-
# Custom logging levels
CUSTOM_BLATHER = 15 # Mapping for zLOG.BLATHER
CUSTOM_TRACE = 5 # Mapping for zLOG.TRACE
@@ -102,94 +97,3 @@
"""Return a simple time string without spaces suitable for logging."""
return ("%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d"
% time.localtime()[:6])
-
-
-def get_env_severity_info():
- """Return the severity setting based on the environment.
-
- The value returned is a zLOG severity, not a logging package severity.
-
- EVENT_LOG_SEVERITY is the preferred envvar, but we accept
- STUPID_LOG_SEVERITY also.
- """
- eget = os.environ.get
- severity = eget('EVENT_LOG_SEVERITY') or eget('STUPID_LOG_SEVERITY')
- if severity:
- severity = int(severity)
- else:
- severity = 0 # INFO
- return severity
-
-
-def get_env_syslog_info():
- eget = os.environ.get
- addr = None
- port = None
- path = eget('ZSYSLOG')
- facility = eget('ZSYSLOG_FACILITY', 'user')
- server = eget('ZSYSLOG_SERVER')
- if server:
- addr, port = server.split(':')
- port = int(port)
- if addr:
- return (facility, (addr, port))
- else:
- return (facility, path)
-
-
-def get_env_file_info():
- """Return the path of the log file to write to based on the
- environment.
-
- EVENT_LOG_FILE is the preferred envvar, but we accept
- STUPID_LOG_FILE also.
- """
- eget = os.environ.get
- return eget('EVENT_LOG_FILE') or eget('STUPID_LOG_FILE')
-
-
-formatters = {
- 'file': Formatter(fmt=('------\n%(asctime)s %(levelname)s %(name)s'
- ' %(message)s'),
- datefmt='%Y-%m-%dT%H:%M:%S'),
- 'syslog': Formatter(fmt='%(levelname)s %(name)s %(message)s'),
- }
-
-def initialize_from_environment():
- """ Reinitialize the event logger from the environment """
- # clear the current handlers from the event logger
- logger = logging.getLogger()
- for h in logger.handlers[:]:
- logger.removeHandler(h)
-
- handlers = []
-
- # set up syslog handler if necessary
- facility, syslogdest = get_env_syslog_info()
- if syslogdest:
- handler = loghandler.SysLogHandler(syslogdest, facility)
- handler.setFormatter(formatters['syslog'])
- handlers.append(handler)
-
- # set up file handler if necessary
- filedest = get_env_file_info()
- if filedest:
- handler = loghandler.FileHandler(filedest)
- handler.setFormatter(formatters['file'])
- handlers.append(handler)
- elif filedest == '':
- # if dest is an empty string, log to standard error
- handler = StreamHandler()
- handler.setFormatter(formatters['file'])
- handlers.append(handler)
- else:
- # log to nowhere, but install a 'null' handler in order to
- # prevent error messages from emanating due to a missing handler
- handlers.append(loghandler.NullHandler())
-
- severity = get_env_severity_info()
- severity = zlog_to_pep282_severity(severity)
- logger.setLevel(severity)
-
- for handler in handlers:
- logger.addHandler(handler)
=== Zope/lib/python/zLOG/__init__.py 1.18 => 1.19 ===
--- Zope/lib/python/zLOG/__init__.py:1.18 Fri Apr 9 15:17:22 2004
+++ Zope/lib/python/zLOG/__init__.py Tue Apr 13 10:28:54 2004
@@ -83,10 +83,7 @@
can be overridden with the environment variable EVENT_LOG_SEVERITY
"""
-__version__='$Revision$'[11:-2]
-
-from EventLogger import log_write, log_time, severity_string, \
- initialize_from_environment
+from EventLogger import log_write, log_time, severity_string
from traceback import format_exception
# Standard severities
@@ -99,16 +96,9 @@
ERROR = 200
PANIC = 300
-# Flag indicating whether LOG() should call initialize()
-_call_initialize = 1
-
-# Function called to (re-)initialize the logger we're using
-_initializer = initialize_from_environment
def initialize():
- global _call_initialize
- _call_initialize = 0
- _initializer()
+ pass
def set_initializer(func):
"""Set the function used to re-initialize the logs.
@@ -119,8 +109,7 @@
This does not ensure that the new function gets called; the caller
should do that separately.
"""
- global _initializer
- _initializer = func
+ pass
def LOG(subsystem, severity, summary, detail='', error=None, reraise=None):
@@ -148,13 +137,11 @@
error is reraised.
"""
- if _call_initialize:
- initialize()
log_write(subsystem, severity, summary, detail, error)
if reraise and error:
raise error[0], error[1], error[2]
-_subsystems=[]
+_subsystems = []
def register_subsystem(subsystem):
"""Register a subsystem name
=== Removed File Zope/lib/python/zLOG/component.xml ===
=== Removed File Zope/lib/python/zLOG/datatypes.py ===
More information about the Zodb-checkins
mailing list