當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。