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

It's not possible to open use 'name' as a LoggingContext keyword argument to be passed to the log message #39

Open
Quidge opened this issue Mar 18, 2022 · 0 comments

Comments

@Quidge
Copy link

Quidge commented Mar 18, 2022

Notice the current __init__ signature for a LoggingContext:

    def __init__(
        self, name=None, *, _prefix=missing, _missing_default=missing, _path_delimiter=".", **kwargs: LoggableValue
    ):

None of these explicitly named arguments can be used as arguments to the contextual data added to a log message. That's fair enough, and we prefixed them with _ because the likelyhood of a user wishing to have a log message with "_prefix": "some value" in the structured data was very low.

However, "name" is a pretty easy want for callers. If I'm a user it's likely that I'm going to run into a situation where I want "name" to be in the contextual data:

with LoggingContext("job:{some_job_name}", name=some_job_name, id=str(uuid4())):
	...

^ It's reasonable to want this.

To address this, we should change the __init__ signature:

    def __init__(
        self, _name=None, *, _prefix=missing, _missing_default=missing, _path_delimiter=".", **kwargs: LoggableValue
    ):

Just make name _name like we're doing for _prefix.

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

No branches or pull requests

1 participant