本文整理汇总了Python中structlog._config.BoundLoggerLazyProxy类的典型用法代码示例。如果您正苦于以下问题:Python BoundLoggerLazyProxy类的具体用法?Python BoundLoggerLazyProxy怎么用?Python BoundLoggerLazyProxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BoundLoggerLazyProxy类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_emphemeral
def test_emphemeral(self):
"""
Calling an unknown method proxy creates a new wrapped bound logger
first.
"""
class Foo(BoundLoggerBase):
def foo(self):
return 42
proxy = BoundLoggerLazyProxy(None, wrapper_class=Foo, cache_logger_on_first_use=False)
assert 42 == proxy.foo()
开发者ID:hynek,项目名称:structlog,代码行数:12,代码来源:test_config.py
示例2: 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
示例3: 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
示例4: 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
示例5: test_new_binds_only_initial_values_explicit_ctx_class
def test_new_binds_only_initial_values_explicit_ctx_class(self, proxy):
proxy = BoundLoggerLazyProxy(None, initial_values={"a": 1, "b": 2}, context_class=dict)
b = proxy.new(foo=42)
assert {"a": 1, "b": 2, "foo": 42} == b._context
开发者ID:hynek,项目名称:structlog,代码行数:4,代码来源:test_config.py
示例6: test_honors_wrapper_class
def test_honors_wrapper_class(self):
p = BoundLoggerLazyProxy(None, wrapper_class=Wrapper)
b = p.bind()
assert isinstance(b, Wrapper)
开发者ID:hynek,项目名称:structlog,代码行数:4,代码来源:test_config.py
示例7: test_unbind_unbinds_from_initial_values
def test_unbind_unbinds_from_initial_values(self):
p = BoundLoggerLazyProxy(None, initial_values={"a": 1, "b": 2})
b = p.unbind("a")
assert {"b": 2} == b._context
开发者ID:hynek,项目名称:structlog,代码行数:4,代码来源:test_config.py
示例8: test_bind_honors_initial_values
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,代码行数:6,代码来源:test_config.py
示例9: test_new_binds_only_initial_values_impolicit_ctx_class
def test_new_binds_only_initial_values_impolicit_ctx_class(self, proxy):
proxy = BoundLoggerLazyProxy(None, initial_values={'a': 1, 'b': 2})
b = proxy.new(foo=42)
assert {'a': 1, 'b': 2, 'foo': 42} == b._context
开发者ID:emfree,项目名称:structlog,代码行数:4,代码来源:test_config.py
注:本文中的structlog._config.BoundLoggerLazyProxy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论