Use str() when json.dumps() finds an unserializable record#59
Open
matt-snider wants to merge 2 commits intovklochan:masterfrom
Open
Use str() when json.dumps() finds an unserializable record#59matt-snider wants to merge 2 commits intovklochan:masterfrom
matt-snider wants to merge 2 commits intovklochan:masterfrom
Conversation
|
I hit this too. In my case the call to logging is from inside django. The code there is outside my control, so I can't work around this easily. @vklochan could you consider merging this and publishing a new version on pypi? @matt-snider thanks for sharing the fix with the world - I only found it after writing my own, inferior solution to the same problem |
Contributor
Author
|
@mozz100 Glad it could be of some use to someone else 😃.Hoping this can be merged at some point soon as well but it's been quite awhile |
|
To me it feels like this project isn't being maintained any more (see https://github.com/vklochan/python-logstash/graphs/code-frequency) Recommend others might be interested in developments at https://github.com/eht16/python-logstash-async |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @vklochan
I ran into a logging error today involving a non-json serializable value in a situation similar to the following:
Which would result in:
Some of this is prevented in formatter.py#L45 where
repr()is called on any non "easy" types. This is essentially what adding the default argument tojson.dumps()would do, with the addition that it would also take care of nested structures. I can of course update my PR to userepr()instead ofstr().