tackle-io/woodchipper

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

Opened this issue · 0 comments

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.