Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using rename fields changes the key order of the log output #7

Closed
nhairs opened this issue Mar 11, 2024 · 1 comment · Fixed by #13
Closed

Using rename fields changes the key order of the log output #7

nhairs opened this issue Mar 11, 2024 · 1 comment · Fixed by #13
Labels
bug Something isn't working enhancement New feature or request

Comments

@nhairs
Copy link
Owner

nhairs commented Mar 11, 2024

Original Issue: madzak/python-json-logger#169

When I rename some of the default field names using rename_fields={key:key} they are logged at the end of the json output.

current behaviour:

Log output without rename fields: {"asctime": "2023-02-21T22:02:12+0100", "levelname": "INFO", "name": "werkzeug", "funcName": "_log", "message": "127.0.0.1"}

Log output with rename fields: {"name": "werkzeug", "funcName": "_log", "message": "127.0.0.1", "time": "2023-02-21T22:02:12+0100", "level": "INFO"}

expected behaviour:

Log output without rename fields: {"asctime": "2023-02-21T22:02:12+0100", "levelname": "INFO", "name": "werkzeug", "funcName": "_log", "message": "127.0.0.1"}

Log output with rename fields: {"time": "2023-02-21T22:02:12+0100", "level": "INFO", "name": "werkzeug", "funcName": "_log", "message": "127.0.0.1"}

--

used version: v2.0.7 used format: "%(asctime)s %(levelname)s %(name)s %(funcName)s %(message)s"

And as a side comment I'm pretty sure this was working as expected a few versions before so some of the newer commits must have changed the behaviour. v2.0.4 works correctly v2.0.5 works unexpectedly

@nhairs nhairs added bug Something isn't working enhancement New feature or request labels Mar 11, 2024
@nhairs
Copy link
Owner Author

nhairs commented Mar 11, 2024

This PR looks like a good candidate: madzak/python-json-logger#176

nhairs added a commit that referenced this issue May 18, 2024
Fixes #6
Fixes #7

Changes also prevent double renaming of fields.

## Test plan

Run tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant