def _setupLogging(): import logging, os, math logConfigFile="espresso_log.conf" if os.path.exists(logConfigFile) : import logging.config logging.config.fileConfig(logConfigFile) log = logging.getLogger('root') log.info('Reading log config file %s', logConfigFile) else : logging.basicConfig( format = "%(process)d %(asctime)s %(name)s (%(filename)s::%(lineno)s,%(funcName)s) %(levelname)s: %(message)s") log = logging.getLogger('root') log.info('Did not find log config file %s, using basic configuration.', logConfigFile) # This initialization routine will change existing and future loggers # to make a connection with their Python logger and change their class def __my_setLevel(self, level): __orig_setLevel(self, level) _espresso.setLogger(self) __orig_setLevel = logging.Logger.setLevel logging.Logger.setLevel = __my_setLevel logging.TRACE = int((logging.NOTSET + logging.DEBUG)/2.0) logging.addLevelName('TRACE', logging.TRACE) _espresso.setLogger()
def __my_setLevel(self, level): __orig_setLevel(self, level) _espresso.setLogger(self)