-
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add drain log hook #11
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thank you for following the naming conventions! 🙏 |
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.
Pull request overview
This pull request adds a new "drain" hook feature to the evlog logging library, enabling users to send logs to external services like Axiom, Loki, or custom endpoints. The feature is designed as a fire-and-forget mechanism that never blocks HTTP responses.
Changes:
- Added
evlog:drainhook that receives aDrainContextcontaining the completeWideEventand optional request metadata - Modified
RequestLogger.emit()to returnWideEvent | nullinstead ofvoid, enabling the drain hook to access the emitted event - Updated internal
emitWideEvent()function to return the formatted event or null when sampled out
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/evlog/src/types.ts | Added DrainContext interface and evlog:drain hook declaration; updated RequestLogger.emit return type |
| packages/evlog/src/logger.ts | Modified emitWideEvent and RequestLogger.emit to return WideEvent | null |
| packages/evlog/src/nitro/plugin.ts | Integrated drain hook calls in error and afterResponse handlers with error handling |
| packages/evlog/src/index.ts | Exported new DrainContext type |
| apps/playground/server/plugins/evlog-drain.ts | Added example implementation of the drain hook |
| apps/docs/content/1.getting-started/2.installation.md | Documented the new drain hook feature with examples |
| AGENTS.md | Added drain hook documentation for AI agents |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces a new "drain" hook (
evlog:drain) to the logging system, enabling easy integration with external log aggregation services (such as Axiom or Loki).The hook is called after a log event is emitted and provides the complete event and relevant request metadata. The changes include updates to the logger internals, type definitions, plugin implementation, and documentation, along with an example plugin for usage reference.