Wrong documentation of logging.setLogRecordFactory?

The documentation here for the logging module reads:


The factory has the following signature:
factory(name, level, fn, lno, msg, args, exc_info, func=None, sinfo=None, **kwargs)

However, when this factory is called some lines later, the code does not pass any kwargs:

rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func, sinfo)

I believe not passing kwargs as such defeats the purpose of setLogRecordFactory so surely this is a bug?

Why does a call that doesn’t pass **kwds defeat the purpose? There are other call sites that do pass additional keywords. The signature given in the docs merely states that the factory has 7 mandatory parameters and 2 optional parameters, all with specific names and meanings, and should accept additional keywords whose meaning is not standardized.

Thanks @guido for your answer. Coming back to this after a few days, I do believe there is not anything that’s necessarily wrong.

Let me clarify what my misunderstanding was, in case anyone from the future cares. When I first read the documentation (esp. the example at the bottom of LogRecord). I got excited at the possibility of passing in arbitrary values as kwargs that could then be added as attributes to the log record. At this point, this doesn’t seem possible as these are taken from extra and not from kwargs. The example cited shows how to add the same attribute to all log records, rather than let the caller decide what to add.

Passing in arbitrary values as kwargs would be a bit nicer than passing in via extra, I think, but this is more minor than what I had (mis)understood at first.