structlog
structlog copied to clipboard
how to get non stdlib async logger
Hi, I am trying to understand how to configure this properly. I was combining this with stdlib before, but I have switched my config now according to the example about performance. I was wondering how to create an async logger like the structlog.stdlib.AsyncBoundLogger
with this setup. Because now it's using make_filtering_bound_logger
which doesn't seem to have an async equivalent.
import logging
import structlog
import orjson
structlog.configure(
cache_logger_on_first_use=True,
wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),
processors=[
structlog.threadlocal.merge_threadlocal_context,
structlog.processors.add_log_level,
structlog.processors.format_exc_info,
structlog.processors.TimeStamper(fmt="iso", utc=False),
structlog.processors.JSONRenderer(serializer=orjson.dumps),
],
logger_factory=structlog.BytesLoggerFactory(),
)
You're right, there is currently no non-stdlib async logger present. The reason is simply because there was more demand for stdlib and I wanted to let it settle first and see if it needs adjustments, before implementing it for non-stdlib too.
I will definitely come, but I don't have a timeline. If you want it now you can copy-paste it together based on https://github.com/hynek/structlog/blob/2f2c2c1e8835507c76c46d5aa6e3ace6aab579fe/src/structlog/stdlib.py#L359
@bluebrown would #457 suit your needs?
Daaamn, I personally love it. Can't wait for the next release.