Skip to content

Conversation

@HugoRCD
Copy link
Owner

@HugoRCD HugoRCD commented Jan 28, 2026

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.

@HugoRCD HugoRCD self-assigned this Jan 28, 2026
@HugoRCD HugoRCD requested a review from Copilot January 28, 2026 09:43
@vercel
Copy link

vercel bot commented Jan 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
evlog-docs Ready Ready Preview, Comment Jan 28, 2026 9:53am

@github-actions
Copy link

github-actions bot commented Jan 28, 2026

Thank you for following the naming conventions! 🙏

Copy link
Contributor

Copilot AI left a 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:drain hook that receives a DrainContext containing the complete WideEvent and optional request metadata
  • Modified RequestLogger.emit() to return WideEvent | null instead of void, 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.

@HugoRCD HugoRCD merged commit e6b83d4 into main Jan 28, 2026
9 of 10 checks passed
@HugoRCD HugoRCD deleted the feat/drain-logs branch January 28, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants