nhairs / python-json-logger

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

asctime handling #17

Open nhairs opened 5 months ago

nhairs commented 5 months ago

Currently using the asctime field will produce a string that is formatted separately from the JSON encoders.

By default it is produced by logging.Formatter.formatTime which uses converter=time.localtime and datefmt.

It feels like instead it should be a datetime encoded by the JSON encoder. However doing this would raise other questions like:

As such any decision to move to using the JSON encoder or changing / removing timestamp is likely a breaking change which we probably want to avoid for as long as possible.

Another approach would be to set "saner" defaults for formatTime or (datefmt and converter). This could be considered a non-breaking change (anyone using defaults would experience the change, but anyone using custom shouldn't see breakages).

Another approach would be to use some kind of "opt-in" keyword argument that toggles new behaviour and otherwise uses old behaviour.

Perhaps in the short term all we do is update the docs to suggest that using timestamp over asctime.

Opinions welcome