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

Serialize log values to json #36

Merged
merged 1 commit into from
Apr 5, 2022

Conversation

simao
Copy link
Contributor

@simao simao commented Apr 5, 2022

Use the kv_unstable_serde feature from log to format values as json, instead of quoting all values.

Previously, numeric or boolean values were formatted as strings, enclosed with double quotes. This is also mentioned in #30

For example (note the time field):

{"level":30,"time":"1649168203900","msg":"--> Response sent","method":"POST","path":"/sensors/inside_weather","status":"200 - OK","duration":"13.777815ms"}

With this change, fields are formatted without quotes, if possible:

{"level":30,"time":1649168203900,"msg":"--> Response sent","method":"POST","path":"/sensors/inside_weather","status":"200 - OK","duration":"13.777815ms"}

This makes filtering with tools like kibana and jq easier. (And jaxe ;))

This also properly formats values in case the app calling log is using nested values, i.e. when value is another json object or a json array. Previously femme would just double quote the json object or array.

Closes #30

@simao simao changed the title Serialize log values in json Serialize log values to json Apr 5, 2022
@simao simao force-pushed the bugfix/serialize-json-vals branch from 84f96cd to 2dce611 Compare April 5, 2022 14:24
@simao simao force-pushed the bugfix/serialize-json-vals branch from 2dce611 to cae2cbd Compare April 5, 2022 14:39
Copy link
Owner

@lrlna lrlna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! thank you, this is great

@lrlna lrlna merged commit e2e59a2 into lrlna:master Apr 5, 2022
@simao simao deleted the bugfix/serialize-json-vals branch April 5, 2022 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Key value formatting
2 participants