From 8374d0b956cf5af7334c4a5196547398873ada7f Mon Sep 17 00:00:00 2001 From: Joshua Boverhof Date: Thu, 9 Sep 2004 23:32:09 +0000 Subject: [PATCH] ---------------------------------------------------------------------- Modified Files: __init__.py -- changed "Base", which contains a logger, to no-op logging if the logging configuration file is not found and avoid the overhead of using the logging module. ---------------------------------------------------------------------- --- __init__.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/__init__.py b/__init__.py index 04b518b..73fa657 100644 --- a/__init__.py +++ b/__init__.py @@ -5,19 +5,32 @@ ident = "$Id$" import WSDLTools import XMLname -from ConfigParser import NoSectionError +from logging import getLogger as _getLogger +import logging.config as _config + LOGGING = 'logging.txt' +DEBUG = True -from logging import getLogger -import logging -import logging.config +# +# If LOGGING configuration file is not found, turn off logging +# and use _noLogger class because logging module's performance +# is terrible. +# try: - logging.config.fileConfig(LOGGING) -except (NoSectionError,), ex: - logging.basicConfig() + _config.fileConfig(LOGGING) +except: + DEBUG = False + class Base: def __init__(self, module=__name__): - self.logger = getLogger('%s-%s(%x)' %(module, self.__class__, id(self))) + self.logger = _noLogger() + if DEBUG is True: + self.logger = _getLogger('%s-%s(%x)' %(module, self.__class__, id(self))) +class _noLogger: + def __init__(self, *args): pass + def warning(self, *args): pass + def debug(self, *args): pass + def error(self, *args): pass