nhairs / nhairs/python-json-logger
asctime handling
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 270
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
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:
- What do we do with the
datefmtargument? - What do we do with the
converterattribute? - Do we remove the
timestampargument?- This could be converted to an alias that adds
asctimetorequired_fieldsand"asctime": "timestamp"torename_fields. Though then what do we do ifasctimeandtimestampare used? - I'll note that there doesn't appear to be any reasoning for why
timestampwas added included in the commit that added it. Searching old issues doesn't surface anything either.
- This could be converted to an alias that adds
- Do we support time zones that aren't UTC?
- What about users still using
asctime,datefmt, andconverter?- Searching old issues - it looks like there people who are using these to control the output of
asctime.
- Searching old issues - it looks like there people who are using these to control the output of
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the current handling of asctime, datefmt, converter, and timestamp, then compare it with Python's logging.Formatter.formatTime behavior. The issue does not name implementation files or tests; work is not ready until the compatibility questions and preferred approach are decided, with documentation updates as the possible short-term outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 24/100