我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用syslog.LOG_NOTICE。
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'])
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'))
def test_emitCustomPriorityOverridesError(self): """ L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} key if it is specified even if the event dictionary represents an error. """ self.observer.emit({ 'message': ('hello, world',), 'isError': True, 'system': '-', 'syslogPriority': stdsyslog.LOG_NOTICE, 'failure': Failure(Exception("bar"))}) self.assertEqual( self.events, [(stdsyslog.LOG_NOTICE, '[-] hello, world')])
def test_levels(journal, logger): """Mapping between log levels and Syslog priorities.""" with JournalHandler().threadbound(): logger.critical('Critical message') assert journal['PRIORITY'] == str(syslog.LOG_CRIT) logger.error('Error message') assert journal['PRIORITY'] == str(syslog.LOG_ERR) logger.warning('Warning message') assert journal['PRIORITY'] == str(syslog.LOG_WARNING) logger.notice('Notice message') assert journal['PRIORITY'] == str(syslog.LOG_NOTICE) logger.info('Info message') assert journal['PRIORITY'] == str(syslog.LOG_INFO) logger.debug('Debug message') assert journal['PRIORITY'] == str(syslog.LOG_DEBUG)