hynek/structlog

Allow renaming keys added by CallsiteParameterAdder

Opened this issue · 0 comments

Currently, CallsiteParameterAdder always adds each parameter under a predetermined key. It would be nice if the user can specify an alternate key for each parameter instead.

A pretty simple to implement and fully backwards compatible way would be to change the init method from

    def __init__(
        self,
        parameters: Collection[CallsiteParameter] = _all_parameters,
        additional_ignores: list[str] | None = None,
    ) -> None:

to

    def __init__(
        self,
        parameters: Collection[CallsiteParameter] | Mapping[str, CallsiteParameter] = _all_parameters,
        additional_ignores: list[str] | None = None,
    ) -> None:

The user can then instantiate the processor as

CallsiteParameterAdder({"tid": allsiteParameter.THREAD, "pid": allsiteParameter.PROCESS})