Python syslog.LOG_ERR Examples
The following are 30
code examples of syslog.LOG_ERR().
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: laikamilter.py From laikaboss with Apache License 2.0 | 6 votes |
def loadScanServers(self): Config = ConfigParser.ConfigParser() try: Config.read(self.configFileLoc) servers = Config.items('ScanServers') for server in servers: self.servers.append(server[1]) except ConfigParser.NoSectionError: if (self.loadAttempt >= self.maxLoadAttempts): log = "Error loading Config File for ScanServers config, USING DEFAULTS" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) else: self.loadError = True log = "Error loading Config File for ScanServers config, should try again" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log)))
Example #2
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 6 votes |
def loadDispositionModes(self): Config = ConfigParser.ConfigParser() try: Config.read(self.configFileLoc) DispositionModes = Config.items('DispositionMode') for DispositionMode in DispositionModes: self.dispositionModes[DispositionMode[0]] = self._convertDispositionMode(DispositionMode[1]) except ConfigParser.NoSectionError: if (self.loadAttempt >= self.maxLoadAttempts): log = "Error loading Config File for DispositionMode config, USING DEFAULTS" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) else: self.loadError = True log = "Error loading Config File for DispositionMode config, should try again" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log)))
Example #3
Source File: libvirt_eventfilter.py From masakari with Apache License 2.0 | 6 votes |
def error_log(msg): syslogout(msg, logLevel=syslog.LOG_ERR) ################################# # Function name: # warn_log # # Function overview: # Output to the syslog(LOG_WARNING level) # # Argument: # msg : Message string # # Return value: # None # #################################
Example #4
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def _writeFileToDisk(self): if self.archiveFileName: try: fp = open(self.archiveFileName, "wb") fp.write(self.fileBuffer) fp.flush() fp.close() except IOError: log = self.uuid+" Could not open "+ self.archiveFileName+ " for writing" self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) #Write Custom header to the file pointer to be written to disk
Example #5
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 #6
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def header(self,name,val): try: lname = name.lower() tname = name.strip() tval = val.strip() headerstring = "%s: %s\n"%(name, val ) self.headers.append(headerstring) self._getSpecialHeaderLines(lname, val) except: log = self.uuid+" Uncaught Exception in Header" self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) return Milter.CONTINUE
Example #7
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def body(self,chunk): # copy body to temp file try: if (isinstance(chunk, str)): chunk = chunk.replace("\r\n", "\n") self.fpb.write(chunk) self.fpb.flush() except: log = self.uuid+" Uncaught Exception in Body" self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) return Milter.CONTINUE
Example #8
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def eom(self): try: self._getQID() checklist = "%s_%s" %(str(self._getIfAddr()), str(self._getClientAddr())) if checklist in global_whitelist: self.logger.writeLog(syslog.LOG_DEBUG, "%s ACCEPT ON WHITELIST: qid:%s client_addr:%s if_addr:%s" %(self.uuid, str(self.qid), str(self._getClientAddr()), str(self._getIfAddr()))) self.rtnToMTA = Milter.ACCEPT else: if not self.alreadyScanned: self._getBufferFromFP()#build the header self._generateArchiveFileName() self.rtnToMTA = self._dispositionMessage() self.fph.write("%s: %s\n"%(self.milterConfig.MailscanResultHeaderString,self.disposition)) self.fph.write("%s: %s\n"%("X-Flags",self.rulesMatched)) self._getBufferFromFP()#Rebuild the buffer with the result header self.fph.close() self.fpb.close() self._writeFileToDisk() self._addHeaders() self._logDetails() self._logEachEnvelope() log = self.uuid+" "+self.qid+" response "+ self.milterConfig._unconvertDispositionMode(self.rtnToMTA) self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(str(log))) self.alreadyScanned = True else: log = self.uuid+" File "+self.archiveFileName+" Already scanned" self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(str(log))) except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() ERROR_INFO = repr(traceback.format_exception(exc_type, exc_value, exc_traceback)) ERROR = "%s ERROR EOM: RETURNING DEFAULT (%s) %s" % (self.uuid, self.rtnToMTA, ERROR_INFO) print ERROR self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(ERROR))) return self.rtnToMTA # END libmilter callbacks # START helper functions # _addHeader adds a single header to the mail message sent to the user
Example #9
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def _addHeader(self,name,value): try: if value: # add header self.addheader(name,value) except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() log = "%s Error adding header %s" % (self.uuid, repr(traceback.format_exception(exc_type, exc_value, exc_traceback))) self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) log = "%s: %s" % (name,value) self.logger.writeLog(syslog.LOG_ERR, "%s Tried to Add: %s"%(self.uuid, str(log))) #_addHeaders adds miltiple headers to the mail message sent to the user
Example #10
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def _checkFilePath(self, path): try: if not os.path.exists(path): os.makedirs(path) except OSError: log = "Could not create "+ path self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log)))
Example #11
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 #12
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def _getReturnToMTAValue(self, dispositioner): if (dispositioner.strScanResult.lower() in self.milterConfig.dispositionModes): rtnToMTA = self.milterConfig.dispositionModes[dispositioner.strScanResult.lower()] else: #Default if not included rtnToMTA = self.milterConfig.dispositionModes["default"] self.logger.writeLog(syslog.LOG_ERR, "Disposition: %s (lc) was not in available dispositions, using default (%s)"%(str(dispositioner.strScanResult.lower()), str(self.milterConfig.dispositionModes["default"]))) return rtnToMTA #_getSpecialHeaderLines grabs headers worth logging
Example #13
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def _getSpecialHeaderLines(self, lname, val): if (lname == "subject"): self.subject = val if (lname == "message-id"): self.messageID = val self.messageID = self.messageID.replace("<", "") self.messageID = self.messageID.replace(">", "") if (lname == "date"): try: self.messageDate = formatdate(mktime_tz(parsedate_tz(val.split('\n')[0])), True) except: log = self.uuid+" Error Parsing "+str(val)+" to RFC822 Date" self.logger.writeLog(syslog.LOG_ERR, "%s"%(str(log)))
Example #14
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 #15
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def close(self): try: self.client.close() except: self.logger.writeLog(syslog.LOG_ERR, self.uuid+" ERROR attempting to close ZMQ context") #public function to get flags from si-scan
Example #16
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 #17
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def loadConfig(self): Config = ConfigParser.ConfigParser() try: Config.read(self.configFileLoc) self.socketname = Config.get('COMMON', 'socketname') self.milterName = Config.get('COMMON', 'MilterName') self.milterInstance = Config.get('COMMON', 'MilterInstance') self.mode = Config.get('COMMON', 'mode') self.zmqMaxRetry = int(Config.get('COMMON', 'zmqMaxRetry')) self.zmqTimeout = int(Config.get('COMMON', 'zmqTimeout')) self.maxFiles = int(Config.get('COMMON', 'maxFiles')) self.heloWhitelist = str(Config.get('COMMON', 'helowhitelist')) self.storeEmails = self._convertTrueFalse(Config.get('ArchiveOptions', 'storeEmails')) self.storeDir = Config.get('ArchiveOptions', 'storeDir') self.customFolderDateFormat = Config.get('ArchiveOptions', 'customFolderDateFormat') except ConfigParser.NoSectionError: if (self.loadAttempt >= self.maxLoadAttempts): log = "Error loading Config File for COMMON config, USING DEFAULTS" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) else: self.loadError = True log = "Error loading Config File for COMMON config, should try again" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log)))
Example #18
Source File: laikamilter.py From laikaboss with Apache License 2.0 | 5 votes |
def loadHeaderOptions(self): Config = ConfigParser.ConfigParser() try: Config.read(self.configFileLoc) self.ApplyCustomHeaders = self._convertTrueFalse(Config.get('HeaderOptions', 'ApplyCustomHeaders')) self.CustomHeaderBase = Config.get('HeaderOptions', 'CustomHeaderBase') self.ApplyMailscanResultHeader = self._convertTrueFalse(Config.get('HeaderOptions', 'ApplyMailscanResultHeader')) self.MailscanResultHeaderString = Config.get('HeaderOptions', 'MailscanResultHeaderString') except ConfigParser.NoSectionError: if (self.loadAttempt >= self.maxLoadAttempts): log = "Error loading Config File for HeaderOptions config, USING DEFAULTS" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) else: self.loadError = True log = "Error loading Config File for HeaderOptions config, should try again" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) except ConfigParser.NoOptionError: if (self.loadAttempt >= self.maxLoadAttempts): log = "Error loading Config File for HeaderOptions config, USING DEFAULTS" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log))) else: self.loadError = True log = "Error loading Config File for HeaderOptions config, should try again" logger = log2syslog(self.milterName, syslog.LOG_LOCAL0) logger.writeLog(syslog.LOG_ERR, "%s"%(str(log)))
Example #19
Source File: belchertown.py From weewx-belchertown with GNU General Public License v3.0 | 5 votes |
def logerr(msg): logmsg(syslog.LOG_ERR, msg) # Print version in syslog for easier troubleshooting
Example #20
Source File: run_containers.py From container-agent with Apache License 2.0 | 5 votes |
def LogError(msg): syslog.syslog(syslog.LOG_LOCAL3 | syslog.LOG_ERR, msg)
Example #21
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 #22
Source File: logging.py From pycopia with Apache License 2.0 | 5 votes |
def error(msg): syslog.syslog(syslog.LOG_ERR, _encode(msg))
Example #23
Source File: logging.py From pycopia with Apache License 2.0 | 5 votes |
def loglevel_error(): loglevel(syslog.LOG_ERR)
Example #24
Source File: alertlib_test.py From alertlib with MIT License | 5 votes |
def test_error_severity(self): alertlib.Alert('test message', severity=logging.ERROR).send_to_logs() self.assertEqual([(syslog.LOG_ERR, 'test message')], self.sent_to_syslog)
Example #25
Source File: test_formats.py From glog-cli with Apache License 2.0 | 5 votes |
def test_format_colored_with_level_error(self): self.message.level = syslog.LOG_ERR log = TailFormatter('({source}) - {message}', color=True).format(self.message) self.assertEquals(colored('(dummy.source) - dummy message', 'red'), log)
Example #26
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 #27
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 #28
Source File: rodi-1.8.py From Aquamonitor with GNU Lesser General Public License v3.0 | 5 votes |
def Close_valve(): Alert("Closing the RO/DI valve", syslog.LOG_NOTICE) try: urllib2.urlopen("http://192.168.0.150/set.cmd?user=admin+pass=12345678+cmd=setpower+p61=0", timeout = 10) time.sleep(5) except urllib2.URLError as e: Send_alert("Cannot communicate with valve: " + type(e), syslog.LOG_ERR)
Example #29
Source File: rodi-1.8.py From Aquamonitor with GNU Lesser General Public License v3.0 | 5 votes |
def Refilling(): try: response = urllib2.urlopen("http://192.168.0.150/set.cmd?user=admin+pass=12345678+cmd=getpower", timeout = 10) content = response.read() time.sleep(2) i = content[10] if int(i) == 1: return True else: return False except urllib2.URLError as e: Send_alert("Cannot communicate with valve: " + type(e), syslog.LOG_ERR)
Example #30
Source File: rodi-1.8.py From Aquamonitor with GNU Lesser General Public License v3.0 | 5 votes |
def Open_valve(): if Refilling() == True: Alert("RO/DI Valve already opened",syslog.LOG_WARNING) sys.exit(5) else: Alert("Opening the RO/DI valve",syslog.LOG_NOTICE) try: urllib2.urlopen("http://192.168.0.150/set.cmd?user=admin+pass=12345678+cmd=setpower+p61=1", timeout = 10) time.sleep(5) except urllib2.URLError as e: Send_alert("Cannot communicate with valve: " + type(e), syslog.LOG_ERR) time.sleep(VALVE_CHGSTATE_TIMER)