Browse Source

----------------------------------------------------------------------

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.

 ----------------------------------------------------------------------
main
Joshua Boverhof 20 years ago
parent
commit
8374d0b956
1 changed files with 21 additions and 8 deletions
  1. +21
    -8
      __init__.py

+ 21
- 8
__init__.py View File

@@ -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

Loading…
Cancel
Save