def test_new_clears_state(self): """ Calling new() on a logger clears the context. """ b = build_bl() b = b.bind(x=42) assert 42 == get_context(b)["x"] b = b.bind() assert 42 == get_context(b)["x"] b = b.new() assert {} == dict(get_context(b))
def test_proxies_try_unbind(self): """ try_unbind calls the correct try_unbind. """ bl = build_bl().bind(a=42).try_unbind("a", "b") assert {} == get_context(bl)
def test_proxies_unbind(self): """ Unbind calls the correct unbind. """ bl = build_bl().bind(a=42).unbind("a") assert {} == get_context(bl)
def test_proxies_new(self): """ Newcalls the correct new. """ bl = build_bl().bind(a=42).new(b=23) assert {"b": 23} == get_context(bl)
def test_proxies_bind(self): """ Bind calls the correct bind. """ bl = build_bl().bind(a=42) assert {"a": 42} == get_context(bl)
def apply_async(self, args=None, kwargs=None, *arguments, **keyword_arguments): logger = log.bind() logger_context = dict(get_context(logger)._dict) kwargs["logger_context"] = logger_context async_result = super().apply_async( args, kwargs, *arguments, **keyword_arguments ) log.info("async_task_created", task_id=async_result.id, task_name=self.name) return async_result