Skip to content

feat: replace LogTape with evlog for wide-event logging - #142

Open
adelrodriguez wants to merge 2 commits into
mainfrom
t3code/evaluate-evlog-migration
Open

feat: replace LogTape with evlog for wide-event logging#142
adelrodriguez wants to merge 2 commits into
mainfrom
t3code/evaluate-evlog-migration

Conversation

@adelrodriguez

@adelrodriguez adelrodriguez commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrates logging from LogTape (five @logtape/* packages) to evlog, adopting the wide-event model: instead of scattered log lines, each API request accumulates context and emits one comprehensive event with method, path, request ID, user identity, custom fields, status, and duration.

{"method":"GET","path":"/hello","requestId":"73206be7…","user":{"id":"usr_123"},"status":200,"durationMs":3,"level":"info","service":"api"}

@init/observability facade

  • loggercreateLogger({ service, drain?, isDevelopment? }) for the per-app singleton, the ambient log API for packages, and structured errors (createError/parseError with why/fix fields)
  • logger/honowithRequestLogging() middleware (one wide event per request, exposed as c.var.log), useLogger() for deep call stacks, LoggerVariables context type
  • logger/drains — Sentry drain behind a batching/retry pipeline; no-op when SENTRY_DSN is unset
  • logger/auth — evlog's first-class Better Auth helpers (identifyUser, createAuthMiddleware, maskEmail)
  • logger/vite — evlog Vite plugin: auto-init plus log.debug stripping from production builds

Consumers

  • api — evlog middleware first in the chain; requireSession stamps user/session onto every authenticated request event; onError logs to the wide event and returns structured { message, why, fix } responses; Better Auth internal logs route through evlog; tRPC context passes log through
  • app / desktop / extension / mobilecreateLogger({ service }) singletons; the Vite-based apps also register the evlog plugin
  • workflows / db / backend / email — Inngest, Drizzle, Convex middleware, and the email mock preview log through the ambient evlog API; LoggerCategory and getLogger are gone

Also fixes stale Axiom references in the observability README and project-structure doc.

Behavior changes

  • Redaction: the custom password/API-key field masking is replaced by evlog's built-in PII redaction (enabled in production, off in development). Custom field paths can be restored via redact: { paths: [...] } on createLogger if desired.
  • Error responses: unhandled API errors now return structured JSON (message/why/fix) instead of plain-text 500s.
  • Child loggers (.with()/.getChild()) flattened to the plain logger — no downstream consumers existed.

Not in this PR

  • Sentry drain for the app server (needs the observability server env imported into apps/app/.env.schema — follow-up; wide events currently emit to the server console)
  • Client log transport/ingestion; browser error capture stays with Sentry's SDK in monitoring/*, unchanged

Testing

  • bun run check (lint + format + types) passes
  • bun test — 22/22 pass
  • Runtime smoke test: Hono request through withRequestLogging emits the wide event above, with c.var.log.set() and useLogger().set() both landing on the same event

🤖 Generated with Claude Code

Update

TanStack Start server-side wide events are now included — implemented with a Start request middleware (withWideEvent, type: "request") instead of the evlog Nitro module. It opens one event per server request (SSR and server function calls), records handler type, server-fn name/file, and response status, and exposes the logger to handlers via context.log.

Replace the five @logtape/* packages with evlog in @init/observability.
The facade now exposes createLogger (per-app singleton init), the ambient
log API, structured errors (createError/parseError), a Hono middleware
that emits one wide event per request, a Sentry drain behind a
batching/retry pipeline, Better Auth helpers, and a Vite plugin that
strips log.debug from production builds.

- API: request-scoped wide events via c.var.log/useLogger, user identity
  stamped on every authenticated request, structured error responses
- Apps: createLogger({ service }) singletons; Vite apps also get the
  evlog plugin
- Packages: Inngest, Drizzle, Convex, and email now log through the
  ambient evlog API; category loggers are gone

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@pullfrog

pullfrog Bot commented Aug 14, 2026

Copy link
Copy Markdown

Your anthropic account is out of credit.

Pullfrog detected a billing-exhausted response from your provider — the agent stopped before completing this run.

Top up anthropic

Credit balance is too low

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog | Using Claude Opus𝕏

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

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

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
init Skipped Skipped Aug 14, 2026 2:32am
init-docs Skipped Skipped Aug 14, 2026 2:32am

Request Review

Wire per-request wide events for the app without the evlog Nitro module:
a Start request middleware (type: 'request') opens the event, records
handler type, server function metadata, and response status, and emits
on completion. Registered ahead of CSRF in requestMiddleware so rejected
requests are logged too. The facade re-exports createRequestLogger for
custom integrations.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel
vercel Bot temporarily deployed to Preview – init August 14, 2026 02:31 Inactive
@vercel
vercel Bot temporarily deployed to Preview – init-docs August 14, 2026 02:31 Inactive
@pullfrog

pullfrog Bot commented Aug 14, 2026

Copy link
Copy Markdown

Your anthropic account is out of credit.

Pullfrog detected a billing-exhausted response from your provider — the agent stopped before completing this run.

Top up anthropic

Credit balance is too low

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog | Using Claude Opus𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant