Skip to content

feat(console-log): Allow configuring logs as JSON#47

Merged
orangejulius merged 1 commit intomasterfrom
allow-configuring-json
Sep 1, 2018
Merged

feat(console-log): Allow configuring logs as JSON#47
orangejulius merged 1 commit intomasterfrom
allow-configuring-json

Conversation

@orangejulius
Copy link
Copy Markdown
Member

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.

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 orangejulius merged commit 7ff7e6c into master Sep 1, 2018
@orangejulius orangejulius deleted the allow-configuring-json branch September 1, 2018 16:36
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
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.

1 participant