當前位置: 首頁>>代碼示例>>Python>>正文


Python syslog.LOG_USER屬性代碼示例

本文整理匯總了Python中syslog.LOG_USER屬性的典型用法代碼示例。如果您正苦於以下問題:Python syslog.LOG_USER屬性的具體用法?Python syslog.LOG_USER怎麽用?Python syslog.LOG_USER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在syslog的用法示例。


在下文中一共展示了syslog.LOG_USER屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_USER [as 別名]
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) 
開發者ID:openstack,項目名稱:oslo.log,代碼行數:13,代碼來源:handlers.py

示例2: setUp

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_USER [as 別名]
def setUp(self):
        super(SysLogHandlersTestCase, self).setUp()
        self.facility = logging.handlers.SysLogHandler.LOG_USER
        self.logger = logging.handlers.SysLogHandler(facility=self.facility) 
開發者ID:openstack,項目名稱:oslo.log,代碼行數:6,代碼來源:test_log.py

示例3: test_syslog_binary_name

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_USER [as 別名]
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) 
開發者ID:openstack,項目名稱:oslo.log,代碼行數:10,代碼來源:test_log.py

示例4: test_find_facility

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_USER [as 別名]
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") 
開發者ID:openstack,項目名稱:oslo.log,代碼行數:10,代碼來源:test_log.py

示例5: test_emit_exception

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_USER [as 別名]
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)) 
開發者ID:openstack,項目名稱:oslo.log,代碼行數:34,代碼來源:test_log.py

示例6: __init__

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_USER [as 別名]
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) 
開發者ID:jd,項目名稱:daiquiri,代碼行數:10,代碼來源:handlers.py

示例7: test_find_facility

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_USER [as 別名]
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")) 
開發者ID:jd,項目名稱:daiquiri,代碼行數:13,代碼來源:test_output.py

示例8: syslogout

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_USER [as 別名]
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
#
################################# 
開發者ID:ntt-sic,項目名稱:masakari,代碼行數:57,代碼來源:libvirt_eventfilter.py


注:本文中的syslog.LOG_USER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。