-
Notifications
You must be signed in to change notification settings - Fork 5
feature: logger hook functions #10
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
Conversation
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.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
} | ||
|
||
[...(hooks[level] || []), ...(hooks['all'] || [])].forEach((hook) => { | ||
hook(message, bindings); |
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.
not sure I understand the purpose behind this, you want to be able to shove side effects right before the log is sent? But the hooks are set one time during app bootstrap, why not use the context interceptor to enrich the context and such new fields enrichment will be done automatically?
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 isn’t meant for enriching the logs themselves, but rather for triggering small side effects right before or after a log is sent (could be changed) - like tracking metrics or triggering alerts.
It’s meant as a lightweight runtime hook without needing to run the same block of code before/after each log, wrap logger functions or modify individual log calls.
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.
as in "also send a sentry when an error is logged?"
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.
yeah, for example..
🎉 This PR is included in version 1.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
added the ability to add hooks functions per each log level or all of them.
hooks are passed in the options param in the module root functions.
example: