当前位置: 首页>>代码示例>>Python>>正文


Python log.INFO属性代码示例

本文整理汇总了Python中oslo_log.log.INFO属性的典型用法代码示例。如果您正苦于以下问题:Python log.INFO属性的具体用法?Python log.INFO怎么用?Python log.INFO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在oslo_log.log的用法示例。


在下文中一共展示了log.INFO属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _validate_keys

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def _validate_keys(self, ctxt, keyed_log_string):
        infocolor = handlers.ColorHandler.LEVEL_COLORS[logging.INFO]
        warncolor = handlers.ColorHandler.LEVEL_COLORS[logging.WARN]
        info_msg = 'info'
        warn_msg = 'warn'
        infoexpected = "%s %s %s" % (infocolor, keyed_log_string, info_msg)
        warnexpected = "%s %s %s" % (warncolor, keyed_log_string, warn_msg)

        self.colorlog.info(info_msg, context=ctxt)
        self.assertIn(infoexpected, self.stream.getvalue())
        self.assertEqual('\033[00;36m', infocolor)

        self.colorlog.warn(warn_msg, context=ctxt)
        self.assertIn(infoexpected, self.stream.getvalue())
        self.assertIn(warnexpected, self.stream.getvalue())
        self.assertEqual('\033[01;33m', warncolor) 
开发者ID:openstack,项目名称:oslo.log,代码行数:18,代码来源:test_log.py

示例2: build_simple_server

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def build_simple_server():
    app = load_app()
    # Create the WSGI server and start it
    host, port = CONF.api.host, CONF.api.port

    LOG.info('Starting server in PID %s', os.getpid())
    LOG.info('Configuration:')
    CONF.log_opt_values(LOG, log.INFO)

    if host == '0.0.0.0':
        LOG.info(
            'serving on 0.0.0.0:%(port)s, view at http://127.0.0.1:%(port)s',
            {'port': port})
    else:
        LOG.info('serving on http://%(host)s:%(port)s',
                 {'host': host, 'port': port})

    LOG.info('"DANGER! For testing only, do not use in production"')

    serving.run_simple(host, port,
                       app, processes=CONF.api.workers) 
开发者ID:openstack,项目名称:vitrage,代码行数:23,代码来源:app.py

示例3: _dump

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def _dump(level, action, phase, reason, timestamp):
    global dispatchers

    if timestamp is None:
        timestamp = timeutils.utcnow(True)

    # We check the logging level threshold only when debug is False
    if cfg.CONF.debug is False:
        watermark = cfg.CONF.dispatchers.priority.upper()
        bound = consts.EVENT_LEVELS.get(watermark, logging.INFO)
        if level < bound:
            return

    if cfg.CONF.dispatchers.exclude_derived_actions:
        if action.cause == consts.CAUSE_DERIVED:
            return

    try:
        dispatchers.map_method("dump", level, action,
                               phase=phase, reason=reason, timestamp=timestamp)
    except Exception as ex:
        LOG.exception("Dispatcher failed to handle the event: %s",
                      str(ex)) 
开发者ID:openstack,项目名称:senlin,代码行数:25,代码来源:event.py

示例4: setup_logging

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def setup_logging(self):
        # Assign default logs to self.LOG so we can still
        # assert on senlin logs.
        default_level = logging.INFO
        if os.environ.get('OS_DEBUG') in _TRUE_VALUES:
            default_level = logging.DEBUG

        self.LOG = self.useFixture(
            fixtures.FakeLogger(level=default_level, format=_LOG_FORMAT))
        base_list = set([nlog.split('.')[0] for nlog in
                         logging.getLogger().logger.manager.loggerDict])
        for base in base_list:
            if base in TEST_DEFAULT_LOGLEVELS:
                self.useFixture(fixtures.FakeLogger(
                    level=TEST_DEFAULT_LOGLEVELS[base],
                    name=base, format=_LOG_FORMAT))
            elif base != 'senlin':
                self.useFixture(fixtures.FakeLogger(
                    name=base, format=_LOG_FORMAT)) 
开发者ID:openstack,项目名称:senlin,代码行数:21,代码来源:base.py

示例5: _log_entry

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def _log_entry(log_type, entry, log_level=logging.INFO, **kwargs):
    delta = datetime.now() - datetime.min
    timestamp = delta.total_seconds()
    log_dict = {'log_type': log_type, 'op': entry.operation,
                'obj_type': entry.object_type, 'obj_id': entry.object_uuid,
                'entry_id': entry.seqnum, 'timestamp': timestamp}
    LOG.log(log_level, LOG_ENTRY_TEMPLATE, log_dict, **kwargs) 
开发者ID:openstack,项目名称:networking-odl,代码行数:9,代码来源:journal.py

示例6: test_will_be_info_if_debug_flag_not_set

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_will_be_info_if_debug_flag_not_set(self):
        self.config(debug=False)
        logger_name = 'test_is_not_debug'
        log.setup(self.CONF, logger_name)
        logger = logging.getLogger(logger_name)
        self.assertEqual(logging.INFO, logger.getEffectiveLevel()) 
开发者ID:openstack,项目名称:oslo.log,代码行数:8,代码来源:test_log.py

示例7: test_handler

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_handler(self):
        handler = handlers.OSSysLogHandler()
        syslog.syslog = mock.Mock()
        handler.emit(
            logging.LogRecord("foo", logging.INFO,
                              "path", 123, "hey!",
                              None, None))
        self.assertTrue(syslog.syslog.called) 
开发者ID:openstack,项目名称:oslo.log,代码行数:10,代码来源:test_log.py

示例8: test_syslog

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_syslog(self):
        msg_unicode = u"Benoît Knecht & François Deppierraz login failure"
        handler = handlers.OSSysLogHandler()
        syslog.syslog = mock.Mock()
        handler.emit(
            logging.LogRecord("name", logging.INFO, "path", 123,
                              msg_unicode, None, None))
        syslog.syslog.assert_called_once_with(syslog.LOG_INFO, msg_unicode) 
开发者ID:openstack,项目名称:oslo.log,代码行数:10,代码来源:test_log.py

示例9: test_emit

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_emit(self):
        logger = log.getLogger('nova-test.foo')
        local_context = _fake_new_context()
        logger.info("Foo", context=local_context)
        self.assertEqual(
            mock.call(mock.ANY, CODE_FILE=mock.ANY, CODE_FUNC='test_emit',
                      CODE_LINE=mock.ANY, LOGGER_LEVEL='INFO',
                      LOGGER_NAME='nova-test.foo', PRIORITY=6,
                      SYSLOG_FACILITY=syslog.LOG_USER,
                      SYSLOG_IDENTIFIER=mock.ANY,
                      REQUEST_ID=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,代码行数:28,代码来源:test_log.py

示例10: test_is_enabled_for

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_is_enabled_for(self):
        self.assertTrue(self.log.isEnabledFor(logging.INFO))
        self.assertFalse(self.log_no_debug.isEnabledFor(logging.DEBUG))
        self.assertTrue(self.log_below_debug.isEnabledFor(logging.DEBUG))
        self.assertTrue(self.log_below_debug.isEnabledFor(7))
        self.assertTrue(self.log_trace.isEnabledFor(log.TRACE)) 
开发者ID:openstack,项目名称:oslo.log,代码行数:8,代码来源:test_log.py

示例11: test_has_level_from_flags

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_has_level_from_flags(self):
        self.assertEqual(logging.INFO, self.log.logger.getEffectiveLevel()) 
开发者ID:openstack,项目名称:oslo.log,代码行数:4,代码来源:test_log.py

示例12: test_child_log_has_level_of_parent_flag

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_child_log_has_level_of_parent_flag(self):
        logger = log.getLogger('nova-test.foo')
        self.assertEqual(logging.INFO, logger.logger.getEffectiveLevel()) 
开发者ID:openstack,项目名称:oslo.log,代码行数:5,代码来源:test_log.py

示例13: test_contextual_information_is_imparted_to_3rd_party_log_records

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_contextual_information_is_imparted_to_3rd_party_log_records(self):
        ctxt = _fake_context()
        sa_log = logging.getLogger('sqlalchemy.engine')
        sa_log.setLevel(logging.INFO)
        message = 'emulate logging within sqlalchemy'
        sa_log.info(message)

        expected = ('HAS CONTEXT [%s]: %s\n' % (ctxt.request_id, message))
        self.assertEqual(expected, self.stream.getvalue()) 
开发者ID:openstack,项目名称:oslo.log,代码行数:11,代码来源:test_log.py

示例14: test_message_logging_3rd_party_log_records

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_message_logging_3rd_party_log_records(self):
        ctxt = _fake_context()
        ctxt.request_id = str('99')
        sa_log = logging.getLogger('sqlalchemy.engine')
        sa_log.setLevel(logging.INFO)
        message = self.trans_fixture.lazy('test ' + chr(128))
        sa_log.info(message)

        expected = ('HAS CONTEXT [%s]: %s\n' % (ctxt.request_id,
                                                str(message)))
        self.assertEqual(expected, self.stream.getvalue()) 
开发者ID:openstack,项目名称:oslo.log,代码行数:13,代码来源:test_log.py

示例15: test_resource_key_in_log_msg

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import INFO [as 别名]
def test_resource_key_in_log_msg(self):
        color = handlers.ColorHandler.LEVEL_COLORS[logging.INFO]
        ctxt = _fake_context()
        resource = 'resource-202260f9-1224-490d-afaf-6a744c13141f'
        fake_resource = {'name': resource}
        message = 'info'
        self.colorlog.info(message, context=ctxt, resource=fake_resource)
        expected = ('%s [%s]: [%s] %s\033[00m\n' %
                    (color, ctxt.request_id, resource, message))
        self.assertEqual(expected, self.stream.getvalue()) 
开发者ID:openstack,项目名称:oslo.log,代码行数:12,代码来源:test_log.py


注:本文中的oslo_log.log.INFO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。