示例#1
0
    def __init__(self, configmod):
        self.delay = configmod.DELAY
        self.name = str(self.__class__).split('.')[-1]
        self._pid_file = os.path.join('/tmp', '%s.pid' % self.name)
        if os.path.exists(self._pid_file):
            raise Exception('''Another instance of %s must be running.
If it i not the case, remove the file %s''' % (self.name, self._pid_file))
        self._alive = 1
        self._sleeping = 0
        treshold = configmod.LOG_TRESHOLD
        if configmod.NODETACH:
            configmod.log = make_logger('print', treshold, self.name).log
        else:
            configmod.log = make_logger('syslog', treshold, self.name).log
        self.config = configmod
示例#2
0
    def __init__(self, configmod) :
        self.delay = configmod.DELAY
        self.name = str(self.__class__).split('.')[-1]
        self._pid_file = os.path.join('/tmp', '%s.pid'%self.name)
        if os.path.exists(self._pid_file):
            raise Exception('''Another instance of %s must be running.
If it i not the case, remove the file %s''' % (self.name, self._pid_file))
        self._alive = 1
        self._sleeping = 0
        treshold = configmod.LOG_TRESHOLD
        if configmod.NODETACH:
            configmod.log = make_logger('print', treshold, self.name).log
        else:
            configmod.log = make_logger('syslog', treshold, self.name).log
        self.config = configmod
示例#3
0
def init_log(treshold, method='eprint', sid='common-log-service',
             logger=None, output=None):
    """init the logging system and and log methods to builtins"""
    if logger is None:
        logger = make_logger(method, treshold, sid, output=output)
    # add log functions and constants to builtins
    __builtins__.update({'log': logger.log,
                         'log_traceback' : logger.log_traceback,
                         'LOG_CRIT':   LOG_CRIT,
                         'LOG_ERR':    LOG_ERR,
                         'LOG_WARN':   LOG_WARN,
                         'LOG_NOTICE': LOG_NOTICE,
                         'LOG_INFO' :  LOG_INFO,
                         'LOG_DEBUG':  LOG_DEBUG,
                         })
示例#4
0
def init_log(treshold,
             method='eprint',
             sid='common-log-service',
             logger=None,
             output=None):
    """init the logging system and and log methods to builtins"""
    if logger is None:
        logger = make_logger(method, treshold, sid, output=output)
    # add log functions and constants to builtins
    __builtins__.update({
        'log': logger.log,
        'log_traceback': logger.log_traceback,
        'LOG_CRIT': LOG_CRIT,
        'LOG_ERR': LOG_ERR,
        'LOG_WARN': LOG_WARN,
        'LOG_NOTICE': LOG_NOTICE,
        'LOG_INFO': LOG_INFO,
        'LOG_DEBUG': LOG_DEBUG,
    })