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


Python log.getLogger方法代码示例

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


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

示例1: setup

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def setup(product_name):
    log.setup(CONF, product_name)

    if CONF.logging_serial_port_settings:
        try:
            serialportlog = SerialPortHandler()
            log_root = log.getLogger(product_name).logger
            log_root.addHandler(serialportlog)

            datefmt = CONF.log_date_format
            serialportlog.setFormatter(
                formatters.ContextFormatter(project=product_name,
                                            datefmt=datefmt))
        except serial.SerialException:
            LOG.warn("Serial port: {0} could not be opened".format(
                     CONF.logging_serial_port_settings)) 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:18,代码来源:log.py

示例2: __init__

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def __init__(self, threads=1000, workers=0):
        os.umask(0o27)  # ensure files are created with the correct privileges
        self._logger = logging.getLogger("eventlet.wsgi.server")
        self._wsgi_logger = loggers.WritableLogger(self._logger)
        self.threads = threads
        self.children = set()
        self.stale_children = set()
        self.running = True
        self.pgid = os.getpid()
        self.workers = workers
        try:
            # NOTE(flaper87): Make sure this process
            # runs in its own process group.
            os.setpgid(self.pgid, self.pgid)
        except OSError:
            # NOTE(flaper87): When running searchlight-control,
            # (searchlight's functional tests, for example)
            # setpgid fails with EPERM as searchlight-control
            # creates a fresh session, of which the newly
            # launched service becomes the leader (session
            # leaders may not change process groups)
            #
            # Running searchlight-api is safe and
            # shouldn't raise any error here.
            self.pgid = 0 
开发者ID:openstack,项目名称:searchlight,代码行数:27,代码来源:wsgi.py

示例3: setUp

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def setUp(self):
        super(NetAppFileStorageLibraryTestCase, self).setUp()

        self.mock_object(na_utils, 'validate_driver_instantiation')

        # Mock loggers as themselves to allow logger arg validation
        mock_logger = log.getLogger('mock_logger')
        self.mock_object(lib_single_svm.LOG,
                         'info',
                         mock.Mock(side_effect=mock_logger.info))

        config = fake.get_config_cmode()
        config.netapp_vserver = fake.VSERVER1

        kwargs = {
            'configuration': config,
            'private_storage': mock.Mock(),
            'app_version': fake.APP_VERSION
        }

        self.library = lib_single_svm.NetAppCmodeSingleSVMFileStorageLibrary(
            fake.DRIVER_NAME, **kwargs)

        self.library._client = mock.Mock()
        self.client = self.library._client 
开发者ID:openstack,项目名称:manila,代码行数:27,代码来源:test_lib_single_svm.py

示例4: setUp

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def setUp(self):
        super(LogLevelTestCase, self).setUp()
        levels = self.CONF.default_log_levels
        info_level = 'nova-test'
        warn_level = 'nova-not-debug'
        other_level = 'nova-below-debug'
        trace_level = 'nova-trace'
        levels.append(info_level + '=INFO')
        levels.append(warn_level + '=WARN')
        levels.append(other_level + '=7')
        levels.append(trace_level + '=TRACE')
        self.config(default_log_levels=levels)
        log.setup(self.CONF, 'testing')
        self.log = log.getLogger(info_level)
        self.log_no_debug = log.getLogger(warn_level)
        self.log_below_debug = log.getLogger(other_level)
        self.log_trace = log.getLogger(trace_level) 
开发者ID:openstack,项目名称:oslo.log,代码行数:19,代码来源:test_log.py

示例5: test_excepthook_logs_exception

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def test_excepthook_logs_exception(self):
        product_name = 'somename'
        exc_log = log.getLogger(product_name)

        self._add_handler_with_cleanup(exc_log)
        excepthook = log._create_logging_excepthook(product_name)

        try:
            raise Exception('Some error happened')
        except Exception:
            excepthook(*sys.exc_info())

        expected_string = ("CRITICAL somename [-] Unhandled error: "
                           "Exception: Some error happened")
        self.assertIn(expected_string, self.stream.getvalue(),
                      message="Exception is not logged") 
开发者ID:openstack,项目名称:oslo.log,代码行数:18,代码来源:test_log.py

示例6: test_rfc5424_isotime_format

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def test_rfc5424_isotime_format(self):
        self.config(
            logging_default_format_string="%(isotime)s %(message)s",
            logging_exception_prefix="%(isotime)s ",
        )

        product_name = 'somename'
        exc_log = log.getLogger(product_name)

        self._add_handler_with_cleanup(exc_log)
        excepthook = log._create_logging_excepthook(product_name)

        message = 'Some error happened'
        try:
            raise Exception(message)
        except Exception:
            excepthook(*sys.exc_info())

        expected_string = ("2015-12-16T13:54:26.517893+00:00 "
                           "Exception: %s" % message)
        self.assertIn(expected_string,
                      self.stream.getvalue()) 
开发者ID:openstack,项目名称:oslo.log,代码行数:24,代码来源:test_log.py

示例7: test_remove_logger

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def test_remove_logger(self):
        fake_handler = {'class': 'logging.StreamHandler'}
        fake_logger = {'level': 'WARN'}
        conf1 = {'root': {'handlers': 'fake'},
                 'handlers': {'fake': fake_handler},
                 'loggers': {'a.a': fake_logger}}
        conf2 = {'root': {'handlers': 'fake'},
                 'handlers': {'fake': fake_handler}}
        stream = io.StringIO()
        with self.mutate_conf(conf1, conf2) as (loginis, confs):
            stream = self.set_root_stream()
            log = logging.getLogger("a.a")
            log.info("info")
            log.warn("warn")
            self.assertEqual("warn\n", stream.getvalue())
        stream = self.set_root_stream()
        log.info("info")
        log.warn("warn")
        self.assertEqual("info\nwarn\n", stream.getvalue()) 
开发者ID:openstack,项目名称:oslo.log,代码行数:21,代码来源:test_log.py

示例8: main

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def main():
    api_config.parse_args(sys.argv)
    logging.setup(CONF, "masakari")
    log = logging.getLogger(__name__)
    objects.register_all()

    launcher = service.process_launcher()
    try:
        server = service.WSGIService("masakari_api", use_ssl=CONF.use_ssl)
        launcher.launch_service(server, workers=server.workers or 1)
    except exception.PasteAppNotFound as ex:
        log.error("Failed to start ``masakari_api`` service. Error: %s",
                  six.text_type(ex))
        sys.exit(1)

    launcher.wait() 
开发者ID:openstack,项目名称:masakari,代码行数:18,代码来源:api.py

示例9: initialize_application

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def initialize_application():
    conf_files = _get_config_files()
    api_config.parse_args([], default_config_files=conf_files)
    logging.setup(CONF, "masakari")

    objects.register_all()
    CONF(sys.argv[1:], project='masakari', version=version.version_string())

    # NOTE: Dump conf at debug (log_options option comes from oslo.service)
    # This is gross but we don't have a public hook into oslo.service to
    # register these options, so we are doing it manually for now;
    # remove this when we have a hook method into oslo.service.
    CONF.register_opts(service_opts.service_opts)
    if CONF.log_options:
        CONF.log_opt_values(logging.getLogger(__name__), logging.DEBUG)

    config.set_middleware_defaults()
    rpc.init(CONF)
    conf = conf_files[0]

    return deploy.loadapp('config:%s' % conf, name="masakari_api") 
开发者ID:openstack,项目名称:masakari,代码行数:23,代码来源:api.py

示例10: main_app

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def main_app(func):
    def _wrapper(global_config, **local_conf):
        # Queuing initialization
        queue.init(CONF, is_server_side=False)

        # Configure oslo logging and configuration services.
        log.setup(CONF, 'barbican')

        config.setup_remote_pydev_debug()

        # Initializing the database engine and session factory before the app
        # starts ensures we don't lose requests due to lazy initialization of
        # db connections.
        repositories.setup_database_engine_and_factory()

        wsgi_app = func(global_config, **local_conf)

        if newrelic_loaded:
            wsgi_app = newrelic.agent.WSGIApplicationWrapper(wsgi_app)
        LOG = log.getLogger(__name__)
        LOG.info(u._LI('Barbican app created and initialized'))
        return wsgi_app
    return _wrapper 
开发者ID:cloud-security-research,项目名称:sgx-kms,代码行数:25,代码来源:app.py

示例11: main

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def main():
    try:
        CONF = config.CONF

        # Import and configure logging.
        log.setup(CONF, 'barbican')
        LOG = log.getLogger(__name__)
        LOG.debug("Booting up Barbican worker node...")

        # Queuing initialization
        queue.init(CONF)

        service.launch(
            CONF,
            server.TaskServer(),
            workers=CONF.queue.asynchronous_workers
        ).wait()
    except RuntimeError as e:
        fail(1, e) 
开发者ID:cloud-security-research,项目名称:sgx-kms,代码行数:21,代码来源:worker.py

示例12: main

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def main():
    try:
        CONF = config.CONF

        # Import and configure logging.
        log.setup(CONF, 'barbican-retry-scheduler')
        LOG = log.getLogger(__name__)
        LOG.debug("Booting up Barbican worker retry/scheduler node...")

        # Queuing initialization (as a client only).
        queue.init(CONF, is_server_side=False)

        service.launch(
            CONF,
            retry_scheduler.PeriodicServer()
        ).wait()
    except RuntimeError as e:
        fail(1, e) 
开发者ID:cloud-security-research,项目名称:sgx-kms,代码行数:20,代码来源:retry_scheduler.py

示例13: main

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def main():
    try:
        CONF = config.CONF
        CONF(sys.argv[1:], project='barbican',
             version=version.version_info.version_string)

        # Import and configure logging.
        log.setup(CONF, 'barbican')
        LOG = log.getLogger(__name__)
        LOG.debug("Booting up Barbican worker node...")

        # Queuing initialization
        queue.init(CONF)

        service.launch(
            CONF,
            server.TaskServer(),
            workers=CONF.queue.asynchronous_workers,
            restart_method='mutate'
        ).wait()
    except RuntimeError as e:
        fail(1, e) 
开发者ID:openstack,项目名称:barbican,代码行数:24,代码来源:worker.py

示例14: main

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [as 别名]
def main():
    try:
        CONF = config.CONF
        CONF(sys.argv[1:], project='barbican',
             version=version.version_info.version_string)

        # Import and configure logging.
        log.setup(CONF, 'barbican-retry-scheduler')
        LOG = log.getLogger(__name__)
        LOG.debug("Booting up Barbican worker retry/scheduler node...")

        # Queuing initialization (as a client only).
        queue.init(CONF, is_server_side=False)

        service.launch(
            CONF,
            retry_scheduler.PeriodicServer(),
            restart_method='mutate'
        ).wait()
    except RuntimeError as e:
        fail(1, e) 
开发者ID:openstack,项目名称:barbican,代码行数:23,代码来源:retry_scheduler.py

示例15: setup_logging

# 需要导入模块: from oslo_log import log [as 别名]
# 或者: from oslo_log.log import getLogger [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


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