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

chore: clean up logging #572

Merged
merged 2 commits into from
Mar 1, 2020
Merged

chore: clean up logging #572

merged 2 commits into from
Mar 1, 2020

Conversation

bchrobot
Copy link
Member

Winston handles .error(message, err) okay, but not .error(err) by itself. For reability we also
want to make sure the provided message ends with a space so that the concatenated message from the
error is separate.

Due to a winston regression introduced in 3.x, we cannot pass other meta information after the error
without passing error.message and error.stack explicitly. This means we may lose additional error
properties. We cannot destructure the error either (non-iterable properties).

A better fix would be to write a custom log formatter that is error-aware. There are a few examples
on GitHub, but none that looked straightforward. We don't want to break JSON logging and parsing.

https://medium.com/@stieg/winston-3-and-logging-error-stacks-cf70b2111289
winstonjs/winston#1351
winstonjs/winston#1498
winstonjs/winston#1338
winstonjs/winston#1562

Winston handles .error(message, err) okay, but not .error(err) by itself. For reability we also
want to make sure the provided message ends with a space so that the concatenated message from the
error is separate.

Due to a winston regression introduced in 3.x, we cannot pass other meta information after the error
without passing error.message and error.stack explicitly. This means we may lose additional error
properties. We cannot destructure the error either (non-iterable properties).

A better fix would be to write a custom log formatter that is error-aware. There are a few examples
on GitHub, but none that looked straightforward. We don't want to break JSON logging and parsing.
@bchrobot bchrobot merged commit 5e8ef0c into master Mar 1, 2020
@bchrobot bchrobot deleted the chore/clean-up-logging branch March 1, 2020 00:01
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