Conversation
Implements EVL-107. Adds `evlog/fastify` — a Fastify plugin for automatic wide-event logging with full pipeline support (drain, enrich, keep). Exposes `request.evlog` for typed per-request access and `useLogger()` via AsyncLocalStorage for call-stack access. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Thank you for following the naming conventions! 🙏 |
evlog/fastify)Fastify support
…est.log
- Remove `fastify-plugin` runtime dependency (evlog must have zero deps)
- Inline `Symbol.for('skip-override')` to break encapsulation without a package
- Rename `request.evlog` → `request.log` to match Express/Elysia ergonomics
- Update tests, example, docs, and AGENTS.md accordingly
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Add `fastify` scope to PR template and semantic PR CI workflow - Add `example:fastify` script to root package.json - Add Fastify to FeatureFrameworks.vue component (tab 6) - Add #fastify code snippet to landing page - Create docs example page at 6.examples/6.fastify.md Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Remove unused eslint-disable directive, fix no-extra-semi by splitting leading-semicolon expressions, and remove async from route handlers that don't use await (require-await rule). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
storage.enterWith() permanently modifies the async context, so the "throws outside middleware context" test must run before any request that calls enterWith, otherwise the storage is non-null and useLogger() won't throw. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a Fastify plugin for the evlog structured logging library, providing request-scoped wide-event logging with the same pipeline features (drain adapters, enrichers, tail sampling) as existing framework integrations (Express, Elysia, Hono).
Changes:
- Adds
evlog/fastifyplugin withonRequest/onResponse/onErrorlifecycle hooks,useLogger()via AsyncLocalStorage, and plugin encapsulation bypass viaSymbol.for('skip-override') - Adds comprehensive tests and a complete example application with an interactive UI
- Adds documentation, dependency declarations, and build configuration
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
packages/evlog/src/fastify/index.ts |
Core plugin implementation |
packages/evlog/test/fastify.test.ts |
Comprehensive test suite |
packages/evlog/tsdown.config.ts |
Adds fastify entry point to build config |
packages/evlog/package.json |
Adds fastify as dev/peer dependency and export paths |
bun.lock |
Lock file updated with fastify and transitive dependencies |
apps/docs/content/6.examples/6.fastify.md |
Detailed Fastify example documentation |
apps/docs/content/1.getting-started/2.installation.md |
Fastify section in installation guide |
apps/docs/content/0.landing.md |
Fastify tab added to landing page framework showcase |
apps/docs/app/components/features/FeatureFrameworks.vue |
Fastify tab added to framework selector component |
examples/fastify/src/index.ts |
Example Fastify application |
examples/fastify/src/ui.ts |
Interactive web UI for example app |
examples/fastify/package.json |
Example app package configuration |
examples/fastify/tsconfig.json |
TypeScript config for example app |
package.json |
Root script for running the fastify example |
AGENTS.md |
AI agent documentation for Fastify integration |
.github/workflows/semantic-pull-request.yml |
Adds fastify as valid PR scope |
.github/pull_request_template.md |
Adds fastify as valid PR scope in template |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
storage.enterWith() permanently modifies the current async context. In test environments where app.handle() doesn't create a new async context per request, the storage from one request leaks into the next, causing useLogger() to not throw when called outside middleware. Clear the storage at the end of onAfterHandle and onError so that each request leaves a clean state. Also move the "throws outside middleware context" test first in its describe block as an extra guard. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- elysia: replace storage.enterWith(undefined) cleanup with activeLoggers
WeakSet so useLogger() reliably throws when called outside a live request,
regardless of async context persistence in Bun test environments
- elysia: use state.logger in onError instead of storage.getStore()
- fastify: use (request as any).log in onError instead of storage.getStore()
- docs: fix Fastify landing slot (evlog({ drain }) → app.register(evlog, { drain }))
- docs: add { logger: false } to Fastify() in landing and installation docs
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Adds a Fastify plugin for evlog that provides request-scoped logging with wide-event emission.
Changes
New Fastify Plugin (
packages/evlog/src/fastify/index.ts)request.evloguseLogger()for accessing logger from call stack via AsyncLocalStorageonRequest(setup) →onResponse(emit) →onError(error capture)Example Application (
examples/fastify/)Documentation (AGENTS.md, installation.md)
Dependencies
fastify-plugin@^5.0.1as core dependencyfastify@^5.2.1as dev/peer dependencyTests (
packages/evlog/test/fastify.test.ts)