python类syslog()的实例源码

pam_linotp.py 文件源码 项目:linotp-auth-pam-python 作者: LinOTP 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def pam_sm_close_session( pamh, flags, argv ):
    """ pam_sm_close_session """
    syslog.syslog( syslog.LOG_INFO,
                  "Please note: pam_linotp does not support close_session" )
    return pamh.PAM_SERVICE_ERR

##eof##########################################################################
LogWriter.py 文件源码 项目:TOR-Hidden-Service-Verification 作者: arrase 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self):
        syslog.openlog(facility=syslog.LOG_DAEMON)
LogWriter.py 文件源码 项目:TOR-Hidden-Service-Verification 作者: arrase 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def info(self, message):
        syslog.syslog(syslog.LOG_INFO, message)
LogWriter.py 文件源码 项目:TOR-Hidden-Service-Verification 作者: arrase 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def error(self, message):
        syslog.syslog(syslog.LOG_ERR, message)
LogWriter.py 文件源码 项目:TOR-Hidden-Service-Verification 作者: arrase 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def close(self):
        syslog.syslog(syslog.LOG_INFO, 'Closing HSVerifyd')
        syslog.closelog()
daemon.py 文件源码 项目:sc-controller 作者: kozec 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def start(self):
        """Start the daemon."""

        # Check for a pidfile to see if the daemon already runs
        try:
            with open(self.pidfile, 'r') as pidf:
                pid = int(pidf.read().strip())
        except Exception:
            pid = None

        if pid:
            message = "pidfile {0} already exist. " + \
                    "Daemon already running?\n"
            sys.stderr.write(message.format(self.pidfile))
            sys.exit(1)

        # Start the daemon
        self.daemonize()
        syslog.syslog(syslog.LOG_INFO, '{}: started'.format(os.path.basename(sys.argv[0])))
        self.on_start()
        while True:
            try:
                self.run()
            except Exception as e: # pylint: disable=W0703
                syslog.syslog(syslog.LOG_ERR, '{}: {!s}'.format(os.path.basename(sys.argv[0]), e))
            time.sleep(2)
daemon.py 文件源码 项目:sc-controller 作者: kozec 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def stop(self, once=False):
        """Stop the daemon."""

        # Get the pid from the pidfile
        try:
            with open(self.pidfile, 'r') as pidf:
                pid = int(pidf.read().strip())
        except Exception:
            pid = None

        if not pid:
            message = "pidfile {0} does not exist. " + \
                    "Daemon not running?\n"
            sys.stderr.write(message.format(self.pidfile))
            return # not an error in a restart

        # Try killing the daemon process
        try:
            for x in xrange(0, 10): # Waits max 1s
                os.kill(pid, signal.SIGTERM)
                if once: break
                for x in xrange(50):
                    os.kill(pid, 0)
                    time.sleep(0.1)
                time.sleep(0.1)
            os.kill(pid, signal.SIGKILL)
        except OSError as err:
            e = str(err.args)
            if e.find("No such process") > 0:
                if os.path.exists(self.pidfile):
                    os.remove(self.pidfile)
            else:
                print(str(err.args))
                sys.exit(1)
        syslog.syslog(syslog.LOG_INFO, '{}: stopped'.format(os.path.basename(sys.argv[0])))
__init__.py 文件源码 项目:python-application 作者: AGProjects 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, name, facility=syslog.LOG_DAEMON):
        logging.Handler.__init__(self)
        syslog.openlog(name, syslog.LOG_PID, facility)
__init__.py 文件源码 项目:python-application 作者: AGProjects 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def close(self):
        syslog.closelog()
        logging.Handler.close(self)
__init__.py 文件源码 项目:python-application 作者: AGProjects 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def emit(self, record):
        priority = self.priority_map.get(record.levelno, syslog.LOG_INFO)
        message = self.format(record)
        if isinstance(message, unicode):
            message = message.encode('UTF-8')
        for line in message.rstrip().split('\n'):
            syslog.syslog(priority, line)


# noinspection PyMethodMayBeStatic
__init__.py 文件源码 项目:python-application 作者: AGProjects 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def start_syslog(name='python-app', facility=syslog.LOG_DAEMON, capture_stdout=IfNotInteractive, capture_stderr=IfNotInteractive):
    if syslog is Null:
        raise RuntimeError("syslog is not available on this platform")
    for handler in root_logger.handlers[:]:
        root_logger.removeHandler(handler)
    handler = SyslogHandler(name, facility)
    handler.setFormatter(_default_formatter)
    root_logger.addHandler(handler)
    if capture_stdout:
        sys.stdout = StandardIOLogger(root_logger.info)
    if capture_stderr:
        sys.stderr = StandardIOLogger(root_logger.error)
syslogpublisher.py 文件源码 项目:broadview-collector 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        syslog.openlog(ident="BroadView")
syslogpublisher.py 文件源码 项目:broadview-collector 作者: openstack 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __del__(self):
        syslog.closelog()
syslogpublisher.py 文件源码 项目:broadview-collector 作者: openstack 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "BroadView syslog Publisher"
influx.py 文件源码 项目:weewx-influx 作者: matthewwall 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def logmsg(level, msg):
    syslog.syslog(level, 'restx: Influx: %s' % msg)
influx.py 文件源码 项目:weewx-influx 作者: matthewwall 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def logdbg(msg):
    logmsg(syslog.LOG_DEBUG, msg)
influx.py 文件源码 项目:weewx-influx 作者: matthewwall 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def loginf(msg):
    logmsg(syslog.LOG_INFO, msg)
influx.py 文件源码 项目:weewx-influx 作者: matthewwall 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def logerr(msg):
    logmsg(syslog.LOG_ERR, msg)

# some unit labels are rather lengthy.  this reduces them to something shorter.
log_writer.py 文件源码 项目:megadld 作者: arrase 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self):
        syslog.openlog(facility=syslog.LOG_DAEMON)
log_writer.py 文件源码 项目:megadld 作者: arrase 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def info(self, message):
        syslog.syslog(syslog.LOG_INFO, message)


问题


面经


文章

微信
公众号

扫码关注公众号