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


Python BoundLoggerLazyProxy.bind方法代码示例

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


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

示例1: test_bind_doesnt_cache_logger

# 需要导入模块: from structlog._config import BoundLoggerLazyProxy [as 别名]
# 或者: from structlog._config.BoundLoggerLazyProxy import bind [as 别名]
    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,代码行数:17,代码来源:test_config.py

示例2: test_prefers_args_over_config

# 需要导入模块: from structlog._config import BoundLoggerLazyProxy [as 别名]
# 或者: from structlog._config.BoundLoggerLazyProxy import bind [as 别名]
    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,代码行数:19,代码来源:test_config.py

示例3: test_argument_takes_precedence_over_configuration2

# 需要导入模块: from structlog._config import BoundLoggerLazyProxy [as 别名]
# 或者: from structlog._config.BoundLoggerLazyProxy import bind [as 别名]
 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,代码行数:8,代码来源:test_config.py

示例4: test_honors_wrapper_class

# 需要导入模块: from structlog._config import BoundLoggerLazyProxy [as 别名]
# 或者: from structlog._config.BoundLoggerLazyProxy import bind [as 别名]
 def test_honors_wrapper_class(self):
     p = BoundLoggerLazyProxy(None, wrapper_class=Wrapper)
     b = p.bind()
     assert isinstance(b, Wrapper)
开发者ID:hynek,项目名称:structlog,代码行数:6,代码来源:test_config.py

示例5: test_bind_honors_initial_values

# 需要导入模块: from structlog._config import BoundLoggerLazyProxy [as 别名]
# 或者: from structlog._config.BoundLoggerLazyProxy import bind [as 别名]
 def test_bind_honors_initial_values(self):
     p = BoundLoggerLazyProxy(None, initial_values={"a": 1, "b": 2})
     b = p.bind()
     assert {"a": 1, "b": 2} == b._context
     b = p.bind(c=3)
     assert {"a": 1, "b": 2, "c": 3} == b._context
开发者ID:hynek,项目名称:structlog,代码行数:8,代码来源:test_config.py


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