Issue 25508: LogRecord attributes are not tuple, when logging only dict (original) (raw)
Hi,
in doc https://docs.python.org/3.4/library/logging.html#logrecord-attributes there is args You shouldn’t need to format this yourself. The tuple of arguments merged into msg to produce message.
But when I log message with 1 arg - a dict - in record.args will be this dict
import logging
class H(logging.Handler):
def emit(self, record):
print(record.args, type(record.args))
lgr = logging.getLogger()
lgr.addHandler(H())
lgr.error("msg", 1)
lgr.error("msg", dict(a=1))
lgr.error("msg", dict(a=1), 2)
output:
(1,) <class 'tuple'>
{'a': 1} <class 'dict'>
({'a': 1}, 2) <class 'tuple'>