python-json-logger icon indicating copy to clipboard operation
python-json-logger copied to clipboard

feat: add taskName to RESERVED_ATTRS

Open finswimmer opened this issue 2 years ago • 4 comments

taskName was added in Python 3.12. See https://docs.python.org/3/library/logging.html

finswimmer avatar Oct 09 '23 11:10 finswimmer

@madzak, any chance this could be merged soon? 🙏🏻 😊 (And if this repository can no longer be actively maintained, any chance you'd select another maintainer, rather than having folks forking it?)

marccarre avatar May 21 '24 20:05 marccarre

@madzak did you have the time to look at it?

bverhoeve avatar Jul 18 '24 08:07 bverhoeve

This also affects me. This is the best workaround I've found so far in case anyone else needs a quick fix:

class CustomJsonFormatter(jsonlogger.JsonFormatter):
    def __init__(self):
        # 'taskName' was added to the Python 3.12 default log attributes,
        # but only applies to async contexts so we can ignore it.
        # jsonlogger does not yet include this attribute in its `RESERVED_ATTRS`
        # var so we can add it ourselves as a workaround.
        reserved_attrs = jsonlogger.RESERVED_ATTRS
        if not 'taskName' in reserved_attrs:
            reserved_attrs += ('taskName',)
        super().__init__(reserved_attrs=reserved_attrs)

However this PR should really be merged instead to solve the problem for everyone.

em-may avatar Sep 25 '24 14:09 em-may

Hi @em-may,

Just so you're aware it looks like python-json-logger is currently unmaintained, that said I am working on a maintained fork

nhairs avatar Sep 26 '24 01:09 nhairs