Python syslog.openlog() Examples
The following are 26
code examples of syslog.openlog().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
syslog
, or try the search function
.
Example #1
Source File: run_containers.py From container-agent with Apache License 2.0 | 10 votes |
def main(): if len(sys.argv) > 2: Fatal('usage: %s [containers.yaml]' % sys.argv[0]) if len(sys.argv) == 2: with open(sys.argv[1], 'r') as fp: config = yaml.load(fp) else: config = yaml.load(sys.stdin) syslog.openlog(PROGNAME) LogInfo('processing container manifest') CheckVersion(config) all_volumes = LoadVolumes(config.get('volumes', [])) user_containers = LoadUserContainers(config.get('containers', []), all_volumes) CheckGroupWideConflicts(user_containers) if user_containers: infra_containers = LoadInfraContainers(user_containers) RunContainers(infra_containers + user_containers)
Example #2
Source File: util.py From laikaboss with Apache License 2.0 | 5 votes |
def init_logging(): globals()['logFacility'] = getattr(syslog, config.logfacility) globals()['logIdentity'] = config.logidentity globals()['moduleLogLevel'] = getattr(syslog, config.moduleloglevel) globals()['scanLogLevel'] = getattr(syslog, config.scanloglevel) globals()['logResultFromSource'] = config.logresultfromsource syslog.openlog(logIdentity, 0, logFacility) # Keeping this here for legacy purposes. It's now deprecated.
Example #3
Source File: SipLogger.py From rtp_cluster with BSD 2-Clause "Simplified" License | 5 votes |
def safe_open(self): try: syslog.openlog(self.app, syslog.LOG_PID) except Exception as e: print(e)
Example #4
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def __init__(self, name, facility): syslog.openlog(name, 0, facility)
Example #5
Source File: __init__.py From hddfancontrol with GNU General Public License v3.0 | 5 votes |
def __init__(self, facility, options=syslog.LOG_PID): syslog.openlog(logoption=options, facility=facility) super().__init__()
Example #6
Source File: logger.py From backintime with GNU General Public License v2.0 | 5 votes |
def changeProfile(profile_id): name = os.getenv('LOGNAME', 'unknown') syslog.openlog("%s (%s/%s)" %(APP_NAME, name, profile_id))
Example #7
Source File: logger.py From backintime with GNU General Public License v2.0 | 5 votes |
def openlog(): name = os.getenv('LOGNAME', 'unknown') syslog.openlog("%s (%s/1)" %(APP_NAME, name)) atexit.register(closelog)
Example #8
Source File: handlers.py From daiquiri with Apache License 2.0 | 5 votes |
def __init__(self, program_name, facility=None): # Default values always get evaluated, for which reason we avoid # using 'syslog' directly, which may not be available. facility = facility if facility is not None else syslog.LOG_USER if not syslog: raise RuntimeError("Syslog not available on this platform") super(SyslogHandler, self).__init__() syslog.openlog(program_name, 0, facility)
Example #9
Source File: tweetsniff.py From tweetsniff with GNU General Public License v3.0 | 5 votes |
def writeLog(msg): """Output a message to the console/Syslog depending on the host""" if os.name == "posix": syslog.openlog(logoption=syslog.LOG_PID,facility=syslog.LOG_MAIL) syslog.syslog(msg) else: print msg return
Example #10
Source File: core.py From LogESP with MIT License | 5 votes |
def __init__(self): """Initialize trigger engine""" self.rlist = [] self.rules = [] self.newrules = [] self.threads = {} syslog.openlog(facility=syslog.LOG_DAEMON)
Example #11
Source File: list.py From LogESP with MIT License | 5 votes |
def __init__(self, rule): """Initialize trigger object""" self.rule = rule self.tzone = TIME_ZONE self.lasteventid = None self.justfired = False self.timeint = timedelta(minutes=self.rule.time_int) syslog.openlog(facility=syslog.LOG_DAEMON)
Example #12
Source File: core.py From LogESP with MIT License | 5 votes |
def __init__(self): """Initialize trigger engine""" self.rlist = [] self.rules = [] self.newrules = [] self.threads = {} syslog.openlog(facility=syslog.LOG_DAEMON)
Example #13
Source File: core.py From LogESP with MIT License | 5 votes |
def __init__(self): """Initialize sentry core""" self.rule_types = {} self.threads = {} syslog.openlog(facility=syslog.LOG_DAEMON)
Example #14
Source File: logespcore.py From LogESP with MIT License | 5 votes |
def __init__(self): """Initialize daemon core object""" # Open our log facility: syslog.openlog(facility=syslog.LOG_DAEMON)
Example #15
Source File: core.py From LogESP with MIT License | 5 votes |
def __init__(self, config='/opt/LogESP/config/parser.conf'): """Initialize live parser""" self.conf = config self.threads = [] syslog.openlog(facility=syslog.LOG_DAEMON)
Example #16
Source File: parse.py From LogESP with MIT License | 5 votes |
def __init__(self): """Initialize live parser""" self.parser = None self.parser_name = None self.event_type = None self.log_source = None syslog.openlog(facility=syslog.LOG_DAEMON)
Example #17
Source File: syslog_writer.py From radish with MIT License | 5 votes |
def syslog_writer_before_all(self, features): import syslog syslog.openlog("radish") syslog.syslog("begin run {}".format(self.marker))
Example #18
Source File: test_log.py From oslo.log with Apache License 2.0 | 5 votes |
def test_syslog_binary_name(self): # There is no way to test the actual output written to the # syslog (e.g. /var/log/syslog) to confirm binary_name value # is actually present syslog.openlog = mock.Mock() handlers.OSSysLogHandler() syslog.openlog.assert_called_with(handlers._get_binary_name(), 0, syslog.LOG_USER)
Example #19
Source File: handlers.py From oslo.log with Apache License 2.0 | 5 votes |
def __init__(self, facility=None): # Default values always get evaluated, for which reason we avoid # using 'syslog' directly, which may not be available. facility = facility if facility is not None else syslog.LOG_USER # Do not use super() unless type(logging.Handler) is 'type' # (i.e. >= Python 2.7). if not syslog: raise RuntimeError("Syslog not available on this platform") logging.Handler.__init__(self) binary_name = _get_binary_name() syslog.openlog(binary_name, 0, facility)
Example #20
Source File: logger.py From clonedigger with GNU General Public License v3.0 | 5 votes |
def __init__(self, threshold, sid=None, encoding='UTF-8'): import syslog AbstractLogger.__init__(self, threshold) if sid is None: sid = 'syslog' self.encoding = encoding syslog.openlog(sid, syslog.LOG_PID)
Example #21
Source File: SipLogger.py From b2bua with BSD 2-Clause "Simplified" License | 5 votes |
def safe_open(self): try: syslog.openlog(self.app, syslog.LOG_PID) except Exception as e: print(e)
Example #22
Source File: staticip.py From HPN-Scripting with MIT License | 5 votes |
def main(): config = get_config_port_ip() list_live_ip(config) for i in config.keys(): if arp(i) == config[i]: continue if arp(i) == 'none': syslog.openlog( 'WARNING', 0, syslog.LOG_LOCAL7 ) syslog.syslog(syslog.LOG_ALERT, '%s %s IS NOT ACTIVE ' % (socket.gethostname(), i)) else: syslog.openlog( 'WARNING', 0, syslog.LOG_LOCAL4 ) syslog.syslog(syslog.LOG_ALERT, '%s %s IS IN WRONG PORT %s AND SHOULD BE IN %s ' % (socket.gethostname(), i, arp(i),config[i] ))
Example #23
Source File: kindle_logging.py From librariansync with GNU General Public License v3.0 | 5 votes |
def log(program, function, msg, level="I", display=True): global LAST_SHOWN # open syslog syslog.openlog("system: %s %s:%s:" % (level, program, function)) # set priority priority = syslog.LOG_INFO if level == "E": priority = syslog.LOG_ERR elif level == "W": priority = syslog.LOG_WARNING priority |= syslog.LOG_LOCAL4 # write to syslog syslog.syslog(priority, msg) # # NOTE: showlog / showlog -f to check the logs # if display: program_display = " %s: " % program displayed = " " # If loglevel is anything else than I, add it to our tag if level != "I": displayed += "[%s] " % level displayed += utf8_str(msg) # print using FBInk (via cFFI) fbink.fbink_print(fbink.FBFD_AUTO, "%s\n%s" % (program_display, displayed), FBINK_CFG)
Example #24
Source File: gensyslog.py From genmon with GNU General Public License v2.0 | 5 votes |
def SendNotice(Message): try: syslog.openlog("genmon") syslog.syslog("%s" % Message) syslog.closelog() except Exception as e1: log.error("Error: " + str(e1)) console.error("Error: " + str(e1)) #------------------- Command-line interface for gengpio ------------------------
Example #25
Source File: NotifySyslog.py From apprise with MIT License | 4 votes |
def __init__(self, facility=None, log_pid=True, log_perror=False, **kwargs): """ Initialize Syslog Object """ super(NotifySyslog, self).__init__(**kwargs) if facility: try: self.facility = SYSLOG_FACILITY_MAP[facility] except KeyError: msg = 'An invalid syslog facility ' \ '({}) was specified.'.format(facility) self.logger.warning(msg) raise TypeError(msg) else: self.facility = \ SYSLOG_FACILITY_MAP[ self.template_tokens['facility']['default']] # Logging Options self.logoptions = 0 # Include PID with each message. # This may not appear evident if using journalctl since the pid # will always display itself; however it will appear visible # for log_perror combinations self.log_pid = log_pid # Print to stderr as well. self.log_perror = log_perror if log_pid: self.logoptions |= syslog.LOG_PID if log_perror: self.logoptions |= syslog.LOG_PERROR # Initialize our loggig syslog.openlog( self.app_id, logoption=self.logoptions, facility=self.facility) return
Example #26
Source File: NotifySyslog.py From bazarr with GNU General Public License v3.0 | 4 votes |
def __init__(self, facility=None, log_pid=True, log_perror=False, **kwargs): """ Initialize Syslog Object """ super(NotifySyslog, self).__init__(**kwargs) if facility: try: self.facility = SYSLOG_FACILITY_MAP[facility] except KeyError: msg = 'An invalid syslog facility ' \ '({}) was specified.'.format(facility) self.logger.warning(msg) raise TypeError(msg) else: self.facility = \ SYSLOG_FACILITY_MAP[ self.template_tokens['facility']['default']] # Logging Options self.logoptions = 0 # Include PID with each message. # This may not appear evident if using journalctl since the pid # will always display itself; however it will appear visible # for log_perror combinations self.log_pid = log_pid # Print to stderr as well. self.log_perror = log_perror if log_pid: self.logoptions |= syslog.LOG_PID if log_perror: self.logoptions |= syslog.LOG_PERROR # Initialize our loggig syslog.openlog( self.app_id, logoption=self.logoptions, facility=self.facility) return