Python syslog.LOG_DEBUG Examples
The following are 22
code examples of syslog.LOG_DEBUG().
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: libvirt_eventfilter.py From masakari with Apache License 2.0 | 6 votes |
def warn_log(msg): syslogout(msg, logLevel=syslog.LOG_WARNING) ################################# # Function name: # syslogout # # Function overview: # Output to the syslog # # Argument: # msg : Message string # logLevel : Output level to syslog # Default is LOG_DEBUG # # Return value: # None # #################################
Example #2
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 6 votes |
def _dispositionMessage(self): self.startTimeZMQ = time.time() if (not self._checkOKToContinueWithOpenFiles()): self.disposition = "Over Process File Handle Limit" self.logger.writeLog(syslog.LOG_ERR, "Disposition: %s"%(str(self.disposition))) rtnToMTA = self.milterConfig.dispositionModes["OverLimit".lower()] else: dispositioner = Dispositioner(self.logger) success = dispositioner.zmqGetFlagswithRetry(self.milterConfig.zmqMaxRetry, self) self.disposition = dispositioner.strScanResult self.scanPerformedOn = dispositioner.scanServerToUse self.rulesMatched = ' '.join(dispositioner.match) self.warnings = dispositioner.warnings self.attachments = dispositioner.attachements self._dispositionMessage_AttachmentHelper() self.dispositions = dispositioner.dispositions self.logger.writeLog(syslog.LOG_DEBUG, "%s Disposition: %s"%(self.uuid, str(dispositioner.dispositions))) rtnToMTA = self._getReturnToMTAValue(dispositioner) dispositioner.close() self.endTimeZMQ = time.time() return rtnToMTA #_dispositionMessage_AttachmentHelper helps _dispositionMessage convert the attachment list to string.
Example #3
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def abort(self): try: #Try sending it to EOM for scanning and disposition. log = self.uuid+" Aborted QID: "+self.qid+" Attempting to send to direct to EOM" self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(str(log))) self.eom() except: log = self.uuid+" Uncaught Exception in Abort" self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) return Milter.CONTINUE
Example #4
Source File: belchertown.py From weewx-belchertown with GNU General Public License v3.0 | 5 votes |
def logdbg(msg): logmsg(syslog.LOG_DEBUG, msg)
Example #5
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def _zmqSendBuffer(self, milterContext,numRetries, REQUEST_TIMEOUT,SERVER_ENDPOINT): gotResponseFromScanner=-1 self.client = Client(SERVER_ENDPOINT) log = milterContext.uuid+" Sending "+ str(milterContext.qid)+" to "+ SERVER_ENDPOINT self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(str(log))) myhostname = socket.gethostname() externalObject = ExternalObject( buffer=milterContext.fileBuffer, externalVars=ExternalVars( filename=milterContext.archiveFileName, source=milterContext.milterConfig.milterName+"-"+str(myhostname[:myhostname.index(".")]), ephID=milterContext.qid, uniqID=milterContext.messageID ), level=level_metadata ) result = self.client.send(externalObject, retry=numRetries, timeout=REQUEST_TIMEOUT) if result: self.match = flagRollup(result) if not self.match: self.match = [] self.attachements = ','.join(getAttachmentList(result)) strScanResult = finalDispositionFromResult(result) strScanResults= " ".join(dispositionFromResult(result)) if strScanResult: self.strScanResult = strScanResult try: self.dispositions = strScanResults except: self.logger.writeLog(syslog.LOG_ERR, milterContext.uuid+" ERROR getting dispositions via client lib") gotResponseFromScanner=1 else: self.logger.writeLog(syslog.LOG_ERR, milterContext.uuid+" "+str(milterContext.qid)+"| no result object from scanner, returning SCAN ERROR") return gotResponseFromScanner
Example #6
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def _zmqGetFlags(self, numRetries, milterContext): REQUEST_TIMEOUT = milterContext.milterConfig.zmqTimeout gotResponseFromScanner=-1 if (len(self.milterConfig.servers)>0):#servers Available SERVER_ENDPOINT = self._getNextScanServer() gotResponseFromScanner=-1 #Default No Response gotResponseFromScanner = self._zmqSendBuffer(milterContext, numRetries, REQUEST_TIMEOUT, SERVER_ENDPOINT) else: log = "No Scan Servers Defined" self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(str(log))) return gotResponseFromScanner
Example #7
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def _logDetails(self): log = self.uuid+" Flags: %s" % self.rulesMatched self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(str(log)))
Example #8
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def _checkOKToContinueWithOpenFiles(self): okToContinue = True try: pid = os.getpid() try: fd_dir=os.path.join('/proc/', str(pid), 'fd/') except: self.logger.writeLog(syslog.LOG_DEBUG, "Open Files: Problem With PID: "+str(pid)) numOpenFilesOutput = 0 for file in os.listdir(fd_dir): numOpenFilesOutput += 1 if (int(numOpenFilesOutput) > int(self.milterConfig.maxFiles)): self.logger.writeLog(syslog.LOG_ERR, "Open Files: "+str(numOpenFilesOutput)+", Returning "+str(self.milterConfig.dispositionModes["OverLimit".lower()])+" to avoid shutdown at "+str(self.milterConfig.maxFiles)) okToContinue = False else: self.logger.writeLog(syslog.LOG_DEBUG, self.milterConfig.milterInstance+" Open Files: "+str(numOpenFilesOutput)+ " of "+ str(self.milterConfig.maxFiles)) except ValueError: self.logger.writeLog(syslog.LOG_ERR, "Value Error in checkOpenFiles") except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() print "ERROR EOM %s" % (repr(traceback.format_exception(exc_type, exc_value, exc_traceback))) self.logger.writeLog(syslog.LOG_ERR, "Error in checkOpenFiles") return okToContinue #_dispositionMessage main helper function to open dispositioner class to disposition message.
Example #9
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def envrcpt(self,to,*str): try: self.CUSTOMORCPT.append(to) log = self.uuid+" envRcpt: " rcpt = ' '.join(self.CUSTOMORCPT) log += rcpt self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(log)) self.receiver = rcpt self.receiver = self.receiver.replace("<", "") # clean the first "<" off the string self.receiver = self.receiver.replace(">", "") except: log = self.uuid+" Uncaught Exception in EnvRcpt" self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) return Milter.CONTINUE
Example #10
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def envfrom(self,f,*str): try: if self.CUSTOMFROM != "": #If anything is left over from the last email, re -initialize. self.__init__() self.startTime = time.time() self.startTimeDT = datetime.datetime.now() if (self.milterConfig.mode == "shutdown"): log = self.uuid+" Milter in Maint mode, returning [Sender:"+''.join(f)+"]" self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(log)) return self.milterConfig.dispositionModes["InMaintMode".lower()] log = self.uuid+" envFrom: " log += ''.join(f) self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(log)) self.CUSTOMFROM = f self.CUSTOMFROM = self.CUSTOMFROM.replace("<", "") self.CUSTOMFROM = self.CUSTOMFROM.replace(">", "") self.sender = self.CUSTOMFROM self.fph = StringIO.StringIO() self.fpb = StringIO.StringIO() except: log = self.uuid+" Uncaught Exception in EnvFrom" self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) return Milter.CONTINUE #ALWAYS continue to gather the entire email
Example #11
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def hello(self, heloname): returnval = Milter.CONTINUE try: self.logger.writeLog(syslog.LOG_DEBUG, "%s hello:%s client_addr:%s if_addr:%s" %(self.uuid, str(heloname), str(self._getClientAddr()), str(self._getIfAddr()))) self.CUSTOMHELO = heloname except: log = self.uuid+" Uncaught Exception in Hello" self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) return returnval
Example #12
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def unknown(self, cmd): log = self.uuid+" Unknown Callback Received: "+str(cmd) self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(str(log))) return Milter.CONTINUE # Start libmilter callbacks
Example #13
Source File: test_syslog.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def test_emitCustomPriority(self): """ L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} as the syslog priority, if that key is present in the event dictionary. """ self.observer.emit({ 'message': ('hello, world',), 'isError': False, 'system': '-', 'syslogPriority': stdsyslog.LOG_DEBUG}) self.assertEqual( self.events, [(stdsyslog.LOG_DEBUG, '[-] hello, world')])
Example #14
Source File: test_syslog.py From python-for-android with Apache License 2.0 | 5 votes |
def test_emitCustomPriority(self): """ L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} as the syslog priority, if that key is present in the event dictionary. """ self.observer.emit({ 'message': ('hello, world',), 'isError': False, 'system': '-', 'syslogPriority': stdsyslog.LOG_DEBUG}) self.assertEqual( self.events, [(stdsyslog.LOG_DEBUG, '[-] hello, world')])
Example #15
Source File: test_formats.py From glog-cli with Apache License 2.0 | 5 votes |
def test_get_log_level_code(self): self.assertEquals(syslog.LOG_CRIT, LogLevel.find_by_level_name('CRITICAL')) self.assertEquals(syslog.LOG_WARNING, LogLevel.find_by_level_name('WARNING')) self.assertEquals(syslog.LOG_DEBUG, LogLevel.find_by_level_name('DEBUG')) self.assertEquals(syslog.LOG_INFO, LogLevel.find_by_level_name('INFO')) self.assertEquals(syslog.LOG_ERR, LogLevel.find_by_level_name('ERROR')) self.assertEquals(syslog.LOG_NOTICE, LogLevel.find_by_level_name('NOTICE')) self.assertIsNone(LogLevel.find_by_level_name('UNKNOWN'))
Example #16
Source File: test_formats.py From glog-cli with Apache License 2.0 | 5 votes |
def test_get_log_level_from_code(self): self.assertEquals('CRITICAL', LogLevel.find_by_syslog_code(syslog.LOG_CRIT)['name']) self.assertEquals('WARNING', LogLevel.find_by_syslog_code(syslog.LOG_WARNING)['name']) self.assertEquals('DEBUG', LogLevel.find_by_syslog_code(syslog.LOG_DEBUG)['name']) self.assertEquals('INFO', LogLevel.find_by_syslog_code(syslog.LOG_INFO)['name']) self.assertEquals('ERROR', LogLevel.find_by_syslog_code(syslog.LOG_ERR)['name']) self.assertEquals('NOTICE', LogLevel.find_by_syslog_code(syslog.LOG_NOTICE)['name']) self.assertEquals('', LogLevel.find_by_syslog_code(9999)['name'])
Example #17
Source File: test_formats.py From glog-cli with Apache License 2.0 | 5 votes |
def test_format_colored_with_level_debug(self): self.message.level = syslog.LOG_DEBUG log = TailFormatter('({source}) - {message}', color=True).format(self.message) self.assertEquals(colored('(dummy.source) - dummy message', 'cyan'), log)
Example #18
Source File: test_syslog.py From learn_python3_spider with MIT License | 5 votes |
def test_emitCustomPriority(self): """ L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} as the syslog priority, if that key is present in the event dictionary. """ self.observer.emit({ 'message': ('hello, world',), 'isError': False, 'system': '-', 'syslogPriority': stdsyslog.LOG_DEBUG}) self.assertEqual( self.events, [(stdsyslog.LOG_DEBUG, '[-] hello, world')])
Example #19
Source File: logging.py From pycopia with Apache License 2.0 | 5 votes |
def loglevel_debug(): loglevel(syslog.LOG_DEBUG)
Example #20
Source File: logging.py From pycopia with Apache License 2.0 | 5 votes |
def debug(msg): syslog.syslog(syslog.LOG_DEBUG, _encode(msg))
Example #21
Source File: formats.py From bonfire with BSD 3-Clause "New" or "Revised" License | 4 votes |
def tail_format(fields=["source", "facility", "line", "module"], color=True): def format(entry): message_text = entry.message timestamp = entry.timestamp.to('local') level_string = entry.level log_color = 'green' log_background = None if entry.level == syslog.LOG_CRIT: log_color = 'white' log_background = 'on_red' level_string = "CRITICAL" elif entry.level == syslog.LOG_ERR: log_color = 'red' level_string = "ERROR " elif entry.level == syslog.LOG_WARNING: log_color = 'yellow' level_string = "WARNING " elif entry.level == syslog.LOG_NOTICE: log_color = 'green' level_string = "NOTICE " elif entry.level == syslog.LOG_INFO: log_color = 'green' level_string = "INFO " elif entry.level == syslog.LOG_DEBUG: log_color = 'blue' level_string = "DEBUG " if message_text: message_text = " " + message_text + " #" local_fields = list(fields) if "message" in local_fields: local_fields.remove("message") field_text = map(lambda f: "{}:{}".format(f, entry.message_dict.get(f, "")), local_fields) log = "{level_string}[{timestamp}]{message_text} {field_text}".format( timestamp=timestamp.format("YYYY-MM-DD HH:mm:ss.SS"), level_string=level_string, message_text=message_text, field_text="; ".join(field_text)) if color: return colored(log, log_color, log_background) else: return log return format
Example #22
Source File: libvirt_eventfilter.py From masakari with Apache License 2.0 | 4 votes |
def syslogout(msg, logLevel=syslog.LOG_DEBUG, logFacility=syslog.LOG_USER): # Output to the syslog. arg0 = os.path.basename(sys.argv[0]) host = socket.gethostname() logger = logging.getLogger() logger.setLevel(logging.DEBUG) f = "%(asctime)s " + host + \ " %(module)s(%(process)d): %(levelname)s: %(message)s" formatter = logging.Formatter(fmt=f, datefmt='%b %d %H:%M:%S') fh = logging.FileHandler( filename='/var/log/masakari/masakari-instancemonitor.log') fh.setLevel(logging.DEBUG) fh.setFormatter(formatter) logger.addHandler(fh) if logLevel == syslog.LOG_DEBUG: logger.debug(msg) elif logLevel == syslog.LOG_INFO or logLevel == syslog.LOG_NOTICE: logger.info(msg) elif logLevel == syslog.LOG_WARNING: logger.warn(msg) elif logLevel == syslog.LOG_ERR: logger.error(msg) elif logLevel == syslog.LOG_CRIT or \ logLevel == syslog.LOG_ALERT or \ logLevel == syslog.LOG_EMERGE: logger.critical(msg) else: logger.debug(msg) logger.removeHandler(fh) ################################# # Function name: # virEventFilter # # Function overview: # Filter events from libvirt. # # Argument: # eventID : EventID # eventType : Event type # detail : Event name # uuID : UUID # # Return value: # None # #################################