Python syslog.LOG_USER Examples
The following are 9
code examples of syslog.LOG_USER().
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
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
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 #2
Source File: handlers.py From oslo.log with Apache License 2.0 | 5 votes |
def __init__(self, facility=None): if not journal: raise RuntimeError("Systemd bindings do not exist") if not facility: if not syslog: raise RuntimeError("syslog is not available on this platform") facility = syslog.LOG_USER # Do not use super() unless type(logging.Handler) is 'type' # (i.e. >= Python 2.7). logging.Handler.__init__(self) self.binary_name = _get_binary_name() self.facility = facility
Example #3
Source File: test_log.py From oslo.log with Apache License 2.0 | 5 votes |
def setUp(self): super(SysLogHandlersTestCase, self).setUp() self.facility = logging.handlers.SysLogHandler.LOG_USER self.logger = logging.handlers.SysLogHandler(facility=self.facility)
Example #4
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 #5
Source File: test_log.py From oslo.log with Apache License 2.0 | 5 votes |
def test_find_facility(self): self.assertEqual(syslog.LOG_USER, log._find_facility("user")) self.assertEqual(syslog.LOG_LPR, log._find_facility("LPR")) self.assertEqual(syslog.LOG_LOCAL3, log._find_facility("log_local3")) self.assertEqual(syslog.LOG_UUCP, log._find_facility("LOG_UUCP")) self.assertRaises(TypeError, log._find_facility, "fougere")
Example #6
Source File: test_log.py From oslo.log with Apache License 2.0 | 5 votes |
def test_emit_exception(self): logger = log.getLogger('nova-exception.foo') local_context = _fake_new_context() try: raise Exception("Some exception") except Exception: logger.exception("Foo", context=local_context) self.assertEqual( mock.call(mock.ANY, CODE_FILE=mock.ANY, CODE_FUNC='test_emit_exception', CODE_LINE=mock.ANY, LOGGER_LEVEL='ERROR', LOGGER_NAME='nova-exception.foo', PRIORITY=3, SYSLOG_FACILITY=syslog.LOG_USER, SYSLOG_IDENTIFIER=mock.ANY, REQUEST_ID=mock.ANY, EXCEPTION_INFO=mock.ANY, EXCEPTION_TEXT=mock.ANY, PROJECT_NAME='mytenant', PROCESS_NAME='MainProcess', THREAD_NAME='MainThread', USER_NAME='myuser'), self.journal.send.call_args) args, kwargs = self.journal.send.call_args self.assertEqual(len(args), 1) self.assertIsInstance(args[0], str) self.assertIsInstance(kwargs['CODE_LINE'], int) self.assertIsInstance(kwargs['PRIORITY'], int) self.assertIsInstance(kwargs['SYSLOG_FACILITY'], int) del kwargs['CODE_LINE'], kwargs['PRIORITY'], kwargs['SYSLOG_FACILITY'] for key, arg in kwargs.items(): self.assertIsInstance(key, str) self.assertIsInstance(arg, (bytes, str))
Example #7
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 #8
Source File: test_output.py From daiquiri with Apache License 2.0 | 5 votes |
def test_find_facility(self): self.assertEqual(syslog.LOG_USER, output.Syslog._find_facility("user")) self.assertEqual(syslog.LOG_LOCAL1, output.Syslog._find_facility("log_local1")) self.assertEqual(syslog.LOG_LOCAL2, output.Syslog._find_facility("LOG_local2")) self.assertEqual(syslog.LOG_LOCAL3, output.Syslog._find_facility("LOG_LOCAL3")) self.assertEqual(syslog.LOG_LOCAL4, output.Syslog._find_facility("LOCaL4"))
Example #9
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 # #################################