Wide Events Beat Scattered Logs for AI-Assisted Debugging
Wide event pattern mirrors joelclaw's OTEL step telemetry — one rich event per step beats scattered console.logs across system-bus functions, and the why/fix error convention is worth adopting directly.
evlog is a structured logging library built around the “wide event” pattern — instead of scattering console.log calls across a request and generating 10+ lines you’ll have to grep through later, you accumulate context throughout the request lifecycle and emit one rich structured JSON event at the end. The log.set() calls build up a single record: user, cart, payment, order, duration, status — all in one place, all in one query.
The error API is the part worth stealing. createError accepts why and fix fields alongside the message — why: "Card declined by issuer", fix: "Try a different payment method or contact your bank". Self-documenting errors are good for humans debugging at 3am, but the library explicitly frames this as an AI-first design decision: when an agent encounters a failure, structured context with a suggested fix is far more actionable than “Something went wrong” plus a stack trace.
It’s built as a Nitro module, which means it drops in across the entire UnJS ecosystem — Nuxt, TanStack Start, SolidStart, Analog, and anything else Nitro-powered. The middleware auto-injects useLogger(event) into handlers and calls log.emit() automatically at request end — no explicit flush, no manual timing code. There’s a Next.js example in the repo too, though the Nitro path is clearly where it’s most idiomatic.
The wide event pattern maps directly onto how joelclaw’s OTEL telemetry pipeline already works — each Inngest step accumulates structured context and emits one event per step. The why/fix convention on errors is worth considering for createError calls throughout the system-bus functions, where self-describing failures would make agent debugging measurably faster.
Key Ideas
- Wide event pattern: one rich JSON event per request instead of many scattered log lines — all context in one place for one query
- Context accumulation via
log.set()— each handler step adds its own fields to the final event record - Self-documenting errors with
whyandfixfields, explicitly designed to give AI agents actionable context instead of generic messages - Duration tracked automatically — request start to emit, no manual timing
- Nitro module integration via
evlog/nuxtorevlog/nitro— works across Nuxt, TanStack Start, SolidStart, Analog - Sampling support for production:
{ info: 10, warn: 50, debug: 0 }— only sample a percentage of high-volume events - “Wide events” as a concept comes from Honeycomb’s observability literature — evlog brings that pattern down to the middleware layer
- Built by Hugo RCD, active in the UnJS ecosystem