feat(console-log): Allow configuring logs as JSON#47
Merged
orangejulius merged 1 commit intomasterfrom Sep 1, 2018
Merged
Conversation
By setting a flag on the console logger, we can easily convert all outgoing logs with pelias-logger to a JSON format. Many of our log statements already use structured formats, and by printing them in JSON, they can all be readily parsed by almost any log-reading system (like Kibana, Honeycomb, Splunk, etc). In my testing, Winston essentialy checks if the flag is set to any truthy value so `true`, "true", 3, "maybe" and anything else except `null` and `false` will enable this feature. Since it's quite robust and handles any valid value, it does not seem necessary to add any validation ourselves.
orangejulius
added a commit
to pelias/config
that referenced
this pull request
Sep 1, 2018
This is a default value for the change in pelias/logger#47 that allows logs to be configured to be emitted as JSON. Adding the current default value, which keeps JSON logs disabled to avoid making any changes, will help make things more clear.
orangejulius
added a commit
to pelias/config
that referenced
this pull request
Sep 1, 2018
This is a default value for the change in pelias/logger#47 that allows logs to be configured to be emitted as JSON. Adding the current default value, which keeps JSON logs disabled to avoid making any changes, will help make things more clear.
orangejulius
added a commit
that referenced
this pull request
Sep 1, 2018
This forces the JSON output to be on a single line. Without it, it's not easy to parse the logs. Connects #47 See https://github.com/winstonjs/winston/blob/2.4.0/docs/transports.md#console-transport
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.
By setting a flag on the console logger, we can easily convert all
outgoing logs with pelias-logger to a JSON format. Many of our log
statements already use structured formats, and by printing them in JSON,
they can all be readily parsed by almost any log-reading system (like
Kibana, Honeycomb, Splunk, etc).
In my testing, Winston essentialy checks if the flag is set to any
truthy value so
true, "true", 3, "maybe" and anything else exceptnullandfalsewill enable this feature. Since it's quite robust andhandles any valid value, it does not seem necessary to add any
validation ourselves.