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

Python _config.configure函数代码示例

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

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



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

示例1: test_configure_all

    def test_configure_all(self, proxy):
        x = stub()
        configure(processors=[x], context_class=dict)
        b = proxy.bind()

        assert [x] == b._processors
        assert dict is b._context.__class__
开发者ID:hynek,项目名称:structlog,代码行数:7,代码来源:test_config.py


示例2: test_just_processors

 def test_just_processors(self, proxy):
     x = stub()
     configure(processors=[x])
     b = proxy.bind()
     assert [x] == b._processors
     assert _BUILTIN_DEFAULT_PROCESSORS != b._processors
     assert _BUILTIN_DEFAULT_CONTEXT_CLASS == b._context.__class__
开发者ID:hynek,项目名称:structlog,代码行数:7,代码来源:test_config.py


示例3: test_get_logger_passes_positional_arguments_to_logger_factory

 def test_get_logger_passes_positional_arguments_to_logger_factory(self):
     """
     Ensure `get_logger` passes optional positional arguments through to
     the logger factory.
     """
     factory = call_recorder(lambda *args: object())
     configure(logger_factory=factory)
     get_logger("test").bind(x=42)
     assert [call("test")] == factory.calls
开发者ID:hynek,项目名称:structlog,代码行数:9,代码来源:test_config.py


示例4: test_rebinds_bind_method

 def test_rebinds_bind_method(self, proxy):
     """
     To save time, be rebind the bind method once the logger has been
     cached.
     """
     configure(cache_logger_on_first_use=True)
     bind = proxy.bind
     proxy.bind()
     assert bind != proxy.bind
开发者ID:hynek,项目名称:structlog,代码行数:9,代码来源:test_config.py


示例5: test_reset

 def test_reset(self, proxy):
     x = stub()
     configure(processors=[x], context_class=dict, wrapper_class=Wrapper)
     reset_defaults()
     b = proxy.bind()
     assert [x] != b._processors
     assert _BUILTIN_DEFAULT_PROCESSORS == b._processors
     assert isinstance(b, _BUILTIN_DEFAULT_WRAPPER_CLASS)
     assert _BUILTIN_DEFAULT_CONTEXT_CLASS == b._context.__class__
     assert _BUILTIN_DEFAULT_LOGGER_FACTORY is _CONFIG.logger_factory
开发者ID:hynek,项目名称:structlog,代码行数:10,代码来源:test_config.py


示例6: test_bind_doesnt_cache_logger

    def test_bind_doesnt_cache_logger(self):
        """
        Calling configure() changes BoundLoggerLazyProxys immediately.
        Previous uses of the BoundLoggerLazyProxy don't interfere.
        """
        class F(object):
            "New logger factory with a new attribute"
            def a(self, *args):
                return 5

        proxy = BoundLoggerLazyProxy(None)
        proxy.bind()
        configure(logger_factory=F)
        new_b = proxy.bind()
        assert new_b.a() == 5
开发者ID:JTCunning,项目名称:structlog,代码行数:15,代码来源:test_config.py


示例7: test_prefers_args_over_config

    def test_prefers_args_over_config(self):
        p = BoundLoggerLazyProxy(None, processors=[1, 2, 3], context_class=dict)
        b = p.bind()
        assert isinstance(b._context, dict)
        assert [1, 2, 3] == b._processors

        class Class(object):
            def __init__(self, *args, **kw):
                pass

            def update(self, *args, **kw):
                pass

        configure(processors=[4, 5, 6], context_class=Class)
        b = p.bind()
        assert not isinstance(b._context, Class)
        assert [1, 2, 3] == b._processors
开发者ID:hynek,项目名称:structlog,代码行数:17,代码来源:test_config.py


示例8: test_configures_logger_factory

    def test_configures_logger_factory(self):
        def f():
            pass

        configure(logger_factory=f)
        assert f is _CONFIG.logger_factory
开发者ID:hynek,项目名称:structlog,代码行数:6,代码来源:test_config.py


示例9: test_rest_resets_is_configured

 def test_rest_resets_is_configured(self):
     configure()
     reset_defaults()
     assert False is _CONFIG.is_configured
开发者ID:hynek,项目名称:structlog,代码行数:4,代码来源:test_config.py


示例10: test_configure_sets_is_configured

 def test_configure_sets_is_configured(self):
     assert False is _CONFIG.is_configured
     configure()
     assert True is _CONFIG.is_configured
开发者ID:hynek,项目名称:structlog,代码行数:4,代码来源:test_config.py


示例11: test_just_context_class

 def test_just_context_class(self, proxy):
     configure(context_class=dict)
     b = proxy.bind()
     assert dict is b._context.__class__
     assert _BUILTIN_DEFAULT_PROCESSORS == b._processors
开发者ID:hynek,项目名称:structlog,代码行数:5,代码来源:test_config.py


示例12: test_argument_takes_precedence_over_configuration2

 def test_argument_takes_precedence_over_configuration2(self):
     configure(cache_logger_on_first_use=False)
     proxy = BoundLoggerLazyProxy(None, cache_logger_on_first_use=True)
     bind = proxy.bind
     proxy.bind()
     assert bind != proxy.bind
开发者ID:hynek,项目名称:structlog,代码行数:6,代码来源:test_config.py


示例13: test_honors_wrapper_from_config

 def test_honors_wrapper_from_config(self, proxy):
     configure(wrapper_class=Wrapper)
     b = proxy.bind()
     assert isinstance(b, Wrapper)
开发者ID:hynek,项目名称:structlog,代码行数:4,代码来源:test_config.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python _config.BoundLoggerLazyProxy类代码示例发布时间:2022-05-27
下一篇:
Python structlog.get_logger函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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