Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add taskName to RESERVED_ATTRS #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

finswimmer
Copy link

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

taskName was added in Python 3.12
@finswimmer finswimmer marked this pull request as ready for review October 9, 2023 11:59
@marccarre
Copy link

marccarre commented May 21, 2024

@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?)

@bverhoeve
Copy link

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

@em-may
Copy link

em-may commented Sep 25, 2024

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.

@nhairs
Copy link

nhairs commented Sep 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants