本文整理汇总了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
示例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
示例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
示例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)
示例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