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