当前位置: 首页>>代码示例>>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;未经允许,请勿转载。