nhairs / python-json-logger

JSON Formatter for Python Logging
https://nhairs.github.io/python-json-logger/
BSD 2-Clause "Simplified" License
18 stars 4 forks source link

Fix spelling of parameter `json_serialiser` -> `json_serializer` #8

Closed juliangilbey closed 5 months ago

juliangilbey commented 5 months ago

The parameter json_serializer of the JsonFormatter class is publicised and used by other packages when importing and using this package. So its name cannot be changed to json_serialiser. This PR reverts this (possibly inadvertent) change.

juliangilbey commented 5 months ago

One further thought - if you really do want to allow the UK spelling, you could do that as an alternative, something like the following:

    def __init__(
        ...,
        json_serialiser: Union[Callable, str] = json.dumps,
        json_serializer: Union[Callable, str] = json.dumps,
        ...
    ) -> None:
        """
        ...
        :param json_serialiser: a :meth:`json.dumps`-compatible callable
            that will be used to serialize the log record.
        :param json_serializer: an alternative spelling for :param:`json_serialiser`.
        ...
        """
        ...
        if json_serialiser != json.dumps:
            self.json_serializer = self._str_to_fn(json_serialiser)
        else:
            self.json_serializer = self._str_to_fn(json_serializer)
        ...
nhairs commented 5 months ago

Thanks for finding this.

So it looks like this change occurred during 5f85723f when the constructor was changed from **kwags to actual key-word arguments. The "fix" (https://github.com/madzak/python-json-logger/pull/170) was included on the main branch of the upstream but never released, thus it was inadvertently released in 3.0.0.

I'll release it as a patch release (3.0.1)

One further thought - if you really do want to allow the UK spelling, you could do that as an alternative, something like the following:

The library is already using US spelling, lets stick with it :)

juliangilbey commented 5 months ago

Thanks for finding this.

The pleasure of having Debian's amazing CI system; when I uploaded 3.0.0, all of the packages depending on it had their package tests run against the new version!

Thanks for fixing it so quickly, too.