-
Notifications
You must be signed in to change notification settings - Fork 11
Support logging errors as warnings #67
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
Support logging errors as warnings #67
Conversation
ts/base-queue-handler.ts
Outdated
| handleError(err, msg) { | ||
| this.logger.error(err); | ||
| const logLevel = err?.logLevel || 'error'; | ||
| this.logger[logLevel](err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that passing something "erroneous" (even a typo) will result to break the whole handling in base handler of a public library.
A validation would suffice or a parameter to switch between error/warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manoskouvarakis Went with the parameter to switch between error/warning approach.
I used name shouldLogWarning but I'm open to suggestions...
Cytal? cc @DimitrisKalogeropoulos @dktistakis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about logAsWarning ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Either name would be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think logAsWarning best describes what we want to achieve, other than that it's great 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manoskouvarakis @dktistakis @DimitrisKalogeropoulos
I like logAsWarning better too. Done
Also added tests for the new(and the old) functionality
8a38f15
acec39a to
8a38f15
Compare
| ports: | ||
| - '5672:5672' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed in order for tests to "play" locally
https://workable.atlassian.net/browse/PROD-67888
rabbit-queueautomatically logs errors using anerrorlogLevel,but this isn't always desirable by the users of the module
This PR adds basic support for the raiser of the error to be able to specify a boolean
logAsWarningattribute for that error, which will makerabbit-queuelog a warning instead of an error