• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python logs.start_logging函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pulp.server.logs.start_logging函数的典型用法代码示例。如果您正苦于以下问题:Python start_logging函数的具体用法?Python start_logging怎么用?Python start_logging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_root_logger_configured_console

    def test_root_logger_configured_console(self, getLogger, get):
        """
        This test ensures that the root logger is configured appropriately when
        console logging set.
        """
        root_logger = mock.MagicMock(spec=logging.Logger)
        root_logger.manager = mock.MagicMock()
        root_logger.manager.loggerDict = {}

        def fake_getLogger(name=None):
            if name is None:
                return root_logger
            if name not in root_logger.manager.loggerDict:
                root_logger.manager.loggerDict[name] = mock.MagicMock()
            return root_logger.manager.loggerDict[name]
        getLogger.side_effect = fake_getLogger

        logs.start_logging()

        # Let's make sure the handler is setup right
        self.assertEqual(root_logger.addHandler.call_count, 1)
        root_handler = root_logger.addHandler.mock_calls[0][1][0]
        self.assertTrue(isinstance(root_handler, logging.StreamHandler))

        # And the handler should have the formatter with our format string
        self.assertTrue(isinstance(root_handler.formatter, logs.TaskLogFormatter))
开发者ID:release-engineering,项目名称:pulp,代码行数:26,代码来源:test_logs.py


示例2: test_calls__captureWarnings

    def test_calls__captureWarnings(self, _logging):
        """
        Ensure that start_logging() calls captureWarnings().
        """
        logs.start_logging()

        _logging.captureWarnings.assert_called_once_with(True)
开发者ID:nareshbatthula,项目名称:pulp,代码行数:7,代码来源:test_logs.py


示例3: _start_logging

def _start_logging():
    """
    Call into Pulp to get the logging started, and set up the logger to be used in this module.
    """
    global logger
    logs.start_logging()
    logger = logging.getLogger(__name__)
开发者ID:unixbhaskar,项目名称:pulp,代码行数:7,代码来源:manage.py


示例4: test_calls__blacklist_loggers

    def test_calls__blacklist_loggers(self, getLogger, get, _blacklist_loggers):
        """
        Ensure that start_logging() calls _blacklist_loggers().
        """
        logs.start_logging()

        _blacklist_loggers.assert_called_once_with()
开发者ID:nareshbatthula,项目名称:pulp,代码行数:7,代码来源:test_logs.py


示例5: test_root_logger_configured

    def test_root_logger_configured(self, getLogger, get):
        """
        This test ensures that the root logger is configured appropriately.
        """
        root_logger = mock.MagicMock(spec=logging.Logger)
        root_logger.manager = mock.MagicMock()
        root_logger.manager.loggerDict = {}

        def fake_getLogger(name=None):
            if name is None:
                return root_logger
            if name not in root_logger.manager.loggerDict:
                root_logger.manager.loggerDict[name] = mock.MagicMock()
            return root_logger.manager.loggerDict[name]

        getLogger.side_effect = fake_getLogger

        logs.start_logging()

        # Let's make sure the handler is setup right
        self.assertEqual(root_logger.addHandler.call_count, 1)
        root_handler = root_logger.addHandler.mock_calls[0][1][0]
        self.assertTrue(isinstance(root_handler, logs.CompliantSysLogHandler))
        self.assertEqual(root_handler.address, os.path.join("/", "dev", "log"))
        self.assertEqual(root_handler.facility, logs.CompliantSysLogHandler.LOG_DAEMON)

        # And the handler should have the formatter with our format string
        self.assertEqual(root_handler.formatter._fmt, logs.LOG_FORMAT_STRING)
开发者ID:nareshbatthula,项目名称:pulp,代码行数:28,代码来源:test_logs.py


示例6: setUpClass

 def setUpClass(cls):
     if not os.path.exists('/tmp/pulp'):
         os.makedirs('/tmp/pulp')
     stop_logging()
     config_filename = os.path.join(TEST_DATA_DIR, 'test-override-pulp.conf')
     config.config.read(config_filename)
     start_logging()
     manager_factory.initialize()
     constants.DISTRIBUTION_STORAGE_PATH = TEMP_DISTRO_STORAGE_DIR
开发者ID:ATIX-AG,项目名称:pulp_rpm,代码行数:9,代码来源:rpm_support_base.py


示例7: test_calls__captureWarnings_with_attribute_error

    def test_calls__captureWarnings_with_attribute_error(self, _logging):
        """
        Ensure that start_logging() calls captureWarnings() and handles AttributeError
        The validation for this is that the AttributeError is swallowed.
        """
        _logging.captureWarnings.side_effect = AttributeError

        logs.start_logging()

        _logging.captureWarnings.assert_called_once_with(True)
开发者ID:nareshbatthula,项目名称:pulp,代码行数:10,代码来源:test_logs.py


示例8: setUpClass

 def setUpClass(cls):
     if not os.path.exists('/tmp/pulp'):
         os.makedirs('/tmp/pulp')
     stop_logging()
     config_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'test-override-pulp.conf')
     config.config.read(config_filename)
     start_logging()
     name = config.config.get('database', 'name')
     connection.initialize(name)
     manager_factory.initialize()
开发者ID:ehelms,项目名称:pulp,代码行数:10,代码来源:rpm_support_base.py


示例9: _start_logging

def _start_logging():
    """
    Call into Pulp to get the logging started, and set up the logger to be used in this module.
    """
    global logger
    logs.start_logging()
    logger = logging.getLogger(__name__)
    console_handler = logging.StreamHandler()
    console_handler.setLevel(logging.INFO)
    logger.root.addHandler(console_handler)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:10,代码来源:manage.py


示例10: setUpClass

 def setUpClass(cls):
     if not os.path.exists('/tmp/pulp'):
         os.makedirs('/tmp/pulp')
     stop_logging()
     config_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                    '../../../pulp_rpm/test/unit/data', 'test-override-pulp.conf')
     config.config.read(config_filename)
     start_logging()
     name = config.config.get('database', 'name')
     connection.initialize(name)
     manager_factory.initialize()
     constants.DISTRIBUTION_STORAGE_PATH = TEMP_DISTRO_STORAGE_DIR
开发者ID:preethit,项目名称:pulp_rpm,代码行数:12,代码来源:rpm_support_base.py


示例11: load_test_config

def load_test_config():
    if not os.path.exists('/tmp/pulp'):
        os.makedirs('/tmp/pulp')

    override_file = os.path.join(DATA_DIR, 'test-override-pulp.conf')
    stop_logging()
    try:
        config.add_config_file(override_file)
    except RuntimeError:
        pass
    start_logging()

    return config.config
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:13,代码来源:base.py


示例12: load_test_config

def load_test_config():
    if not os.path.exists('/tmp/pulp'):
        os.makedirs('/tmp/pulp')

    override_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'test-override-pulp.conf')
    override_repo_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'test-override-repoauth.conf')
    stop_logging()
    try:
        config.add_config_file(override_file)
        config.add_config_file(override_repo_file)
    except RuntimeError:
        pass
    start_logging()

    return config.config
开发者ID:ehelms,项目名称:pulp,代码行数:15,代码来源:base.py


示例13: _start_logging

def _start_logging():
    """
    Call into Pulp to get the logging started, and set up the _logger to be used in this module.
    """
    global _logger
    logs.start_logging()
    _logger = logging.getLogger(__name__)
    console_handler = logging.StreamHandler()
    console_handler.setLevel(logging.INFO)
    _logger.root.addHandler(console_handler)
    # Django will un-set our default ignoring DeprecationWarning *unless* sys.warnoptions is set.
    # So, set it as though '-W ignore::DeprecationWarning' was passed on the commandline. Our code
    # that sets DeprecationWarnings as ignored also checks warnoptions, so this must be added after
    # pulp.server.logs.start_logging is called but before Django is initialized.
    sys.warnoptions.append('ignore::DeprecationWarning')
开发者ID:alexxa,项目名称:pulp,代码行数:15,代码来源:manage.py


示例14: _load_test_config

def _load_test_config():
    """
    Load the test database configuration information.
    """
    stop_logging()

    config.config.set('database', 'name', 'pulp_unittest')
    config.config.set('server', 'storage_dir', '/tmp/pulp')

    # Prevent the tests from altering the config so that nobody accidentally makes global changes
    config.config.set = _enforce_config
    config.load_configuration = _enforce_config
    config.__setattr__ = _enforce_config
    config.config.__setattr__ = _enforce_config

    start_logging()
开发者ID:jeremycline,项目名称:pulp,代码行数:16,代码来源:base.py


示例15: setUpClass

 def setUpClass(cls):
     if not os.path.exists(cls.TMP_ROOT):
         os.makedirs(cls.TMP_ROOT)
     stop_logging()
     path = os.path.join(
         os.path.abspath(os.path.dirname(__file__)),
         'data',
         'pulp.conf')
     pulp_conf.read(path)
     start_logging()
     storage_dir = pulp_conf.get('server', 'storage_dir')
     if not os.path.exists(storage_dir):
         os.makedirs(storage_dir)
     shutil.rmtree(storage_dir+'/*', ignore_errors=True)
     name = pulp_conf.get('database', 'name')
     connection.initialize(name)
     managers.initialize()
开发者ID:domcleal,项目名称:pulp,代码行数:17,代码来源:base.py


示例16: wsgi_application

def wsgi_application():
    """
    Application factory to create, configure, and return a WSGI application
    using the django framework

    :return: wsgi application callable
    """
    try:
        logger = logging.getLogger(__name__)
        logs.start_logging()
        initialization.initialize()
    except initialization.InitializationException, e:
        logger.fatal('*************************************************************')
        logger.fatal('The Pulp Puppet Forge server failed to start due to the following reasons:')
        logger.exception('  ' + e.message)
        logger.fatal('*************************************************************')
        raise e
开发者ID:daviddavis,项目名称:pulp_puppet,代码行数:17,代码来源:wsgi.py


示例17: setUpClass

    def setUpClass(cls):
        # This will make Celery tasks run synchronously
        celery_instance.celery.conf.CELERY_ALWAYS_EAGER = True

        if not os.path.exists(cls.TMP_ROOT):
            os.makedirs(cls.TMP_ROOT)
        stop_logging()
        path = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'data',
            'pulp.conf')
        pulp_conf.read(path)
        start_logging()
        storage_dir = pulp_conf.get('server', 'storage_dir')
        if not os.path.exists(storage_dir):
            os.makedirs(storage_dir)
        shutil.rmtree(storage_dir+'/*', ignore_errors=True)
        managers.initialize()
开发者ID:credativ,项目名称:pulp,代码行数:18,代码来源:base.py


示例18: _initialize_web_services

def _initialize_web_services():
    """
    This function initializes Pulp for webservices.
    """

    # This initialization order is very sensitive, and each touches a number of
    # sub-systems in pulp. If you get this wrong, you will have pulp tripping
    # over itself on start up.

    global _IS_INITIALIZED, STACK_TRACER
    if _IS_INITIALIZED:
        return

    logs.start_logging()

    # Run the common initialization code that all processes should share. This will start the
    # database connection, initialize plugins, and initialize the manager factory.
    initialization.initialize()

    # configure agent services
    AgentServices.init()

    # Verify the database has been migrated to the correct version. This is
    # very likely a reason the server will fail to start.
    try:
        migration_models.check_package_versions()
    except Exception:
        msg = "The database has not been migrated to the current version. "
        msg += "Run pulp-manage-db and restart the application."
        raise initialization.InitializationException(msg), None, sys.exc_info()[2]

    # There's a significantly smaller chance the following calls will fail.
    # The previous two are likely user errors, but the remainder represent
    # something gone horribly wrong. As such, I'm not going to account for each
    # and instead simply let the exception itself bubble up.

    # start agent services
    AgentServices.start()

    # If we got this far, it was successful, so flip the flag
    _IS_INITIALIZED = True
开发者ID:pcreech,项目名称:pulp,代码行数:41,代码来源:application.py


示例19: test_log_level_invalid

    def test_log_level_invalid(self, getLogger, get):
        """
        Test that we still default to INFO if the user sets some non-existing log level.
        """
        root_logger = mock.MagicMock(spec=logging.Logger)
        root_logger.manager = mock.MagicMock()
        root_logger.manager.loggerDict = {}

        def fake_getLogger(name=None):
            if name is None:
                return root_logger
            root_logger.manager.loggerDict[name] = mock.MagicMock()
            return root_logger.manager.loggerDict[name]
        getLogger.side_effect = fake_getLogger

        logs.start_logging()

        # The config should have been queried for log level
        get.assert_called_once_with('server', 'log_level')
        # We should have defaulted
        root_logger.setLevel.assert_called_once_with(logging.INFO)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:21,代码来源:test_logs.py


示例20: test_log_level_set

    def test_log_level_set(self, getLogger, get):
        """
        Test that we correctly allow users to set their log level.
        """
        root_logger = mock.MagicMock(spec=logging.Logger)
        root_logger.manager = mock.MagicMock()
        root_logger.manager.loggerDict = {}

        def fake_getLogger(name=None):
            if name is None:
                return root_logger
            root_logger.manager.loggerDict[name] = mock.MagicMock()
            return root_logger.manager.loggerDict[name]
        getLogger.side_effect = fake_getLogger

        logs.start_logging()

        # The config should have been queried for log level
        get.assert_called_once_with('server', 'log_level')
        # We should have used the user's setting
        root_logger.setLevel.assert_called_once_with(logging.ERROR)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:21,代码来源:test_logs.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python agent.AgentManager类代码示例发布时间:2022-05-25
下一篇:
Python factory.scheduler函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap