sentry icon indicating copy to clipboard operation
sentry copied to clipboard

fix(logging): updating logging 'throwaways' to Python 3.12 + adding Formatter fields

Open vartec opened this issue 8 months ago • 1 comments

Underlying problem — flake8-logging does not fully catch these if they're coming for a dynamic dictionary rather than a literal.

Changes:

  • Updating the throwaway list of extra fields that class with LogRecord fields to Python 3;
  • Adding "message" and "asctime" which are injected into LogRecord via Formatter and also cause clashes;
  • Adding "taskName" for forwards compatibility with Python 3.12;

The list can be also be auto-generated via:

_rec = logging.makeLogRecord({})
logging.Formatter("%(asctime)s:%(levelname)s:%(name)s:%(message)s").format(_rec)
throwaways = frozenset(rec.__dict__.keys())

vartec avatar Jun 28 '24 20:06 vartec