`get_logger().warning` doesn't take named args like `logging.getLogger().warning`
dijonkitchen opened this issue · comments
Expected behavior:
import logging
logging.getLogger().warning(msg='test logging')
# >>> test logging
import structlog
structlog.stdlib.get_logger().warning(msg="test structlog")
# >>> test structlog
Unexpected behavior:
import structlog
structlog.stdlib.get_logger().warning(msg="test structlog")
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# TypeError: _make_filtering_bound_logger.<locals>.make_method.<locals>.meth() missing 1 required positional argument: 'event'
I guess it would've made sense to rename event
to msg
for stdlib, but then those loggers would be incompatible with every other in the ecosystem so it's a classic catch-22.
Either way, we can't break backwards-compatibility over this at this point. If you really want them to behave that way, it's a simple matter of copy-paste + search-replace.
Thanks, we worked around it by not naming the argument, but could it work in a backwards compatible way if there was an alias and both event
and msg
were concatenated?
That would break log.warning(“foo”, msg=“bar”)
tho. People are doing some amazing weird things with structlog, sadly that makes the maintenance a lot harder. 😅