Skip to content

feat(hono): export useLogger() and enable log.fork() - #476

Merged
HugoRCD merged 2 commits into
mainfrom
feat/hono-use-logger
Aug 1, 2026
Merged

feat(hono): export useLogger() and enable log.fork()#476
HugoRCD merged 2 commits into
mainfrom
feat/hono-use-logger

Conversation

@HugoRCD

@HugoRCD HugoRCD commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Stacked on #470 — both touch the same defineFrameworkIntegration call in src/hono/index.ts. Merge #470 first; the base retargets to main automatically.

What

Hono was the last integration without useLogger(). It now uses createLoggerStorage() like every other one:

// route handler — unchanged, still idiomatic
app.get('/api/pay', (c) => c.get('log').set({ route: 'pay' }))

// a few layers down — no more threading `c` through everything
import { useLogger } from 'evlog/hono'

export async function chargeCard(amount: number) {
  useLogger().set({ payment: { amount } })
}

c.get('log') is not removed or deprecated — both return the same logger.

Bonus: log.fork()

Attaching AsyncLocalStorage also enables log.fork() on Hono, which it previously lacked — the docs explicitly said so:

Hono does not attach log.fork() yet

Background work now emits its own wide event correlated to the request via _parentRequestId.

⚠️ Tradeoff: node:async_hooks on Workers

This is the reason Hono was carved out in the first place, so it deserves a straight answer.

evlog/hono now imports node:async_hooks transitively through evlog/toolkit/storage. I verified this against the built bundle:

dist/hono/index.mjs → ../toolkit/storage.mjs → node:async_hooks

Cloudflare Workers deployments need nodejs_compat (or nodejs_als) in wrangler.toml. Without it, the import fails at build/deploy time. This puts evlog/hono in the same position as express, fastify, nestjs, sveltekit, react-router, orpc and elysia, all of which already import it.

evlog/workers is untouched and stays async_hooks-free — re-verified against dist/workers.mjs (0 references). It remains the path for Workers deployments that cannot enable the flag.

If you'd rather not take that on, the alternative is a separate evlog/hono/logger subpath so the base entry stays clean. I did not do that because it breaks the "same contract everywhere" goal — but say the word and I'll switch it.

Docs & conventions

  • Hono page: new "Accessing the logger deeper in the stack" section, the log.fork() note replaced with a working example, and a callout about the Workers flag
  • AGENTS.md: the Hono does not export useLogger() carve-out is replaced by the general contract every integration is now expected to satisfy, plus the documented reason evlog/workers is the one exception

Verification

  • pnpm run test — 1637/1637 pass (5 new: parity with c.get('log'), resolution through nested async calls, the out-of-request error, filtered-route behaviour, and log.fork() emitting a correlated child event)
  • pnpm run lint — 0 errors (2 pre-existing max-params warnings in nitro-v3/plugin.ts)
  • pnpm run typecheck — 26/26 tasks pass
  • pnpm run api:snapshot — diff is + "useLogger" on ./hono only

@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1160cda

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
evlog Minor
@evlog/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, v0 Aug 1, 2026 4:29pm
evlog-render-lab Ready Ready Preview Aug 1, 2026 4:29pm
evlog-telemetry Ready Ready Preview Aug 1, 2026 4:29pm
just-use-evlog Ready Ready Preview Aug 1, 2026 4:29pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@HugoRCD, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 9 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: af328d81-11d8-4d74-9f1f-2124424fb5df

📥 Commits

Reviewing files that changed from the base of the PR and between 4e12ebb and 1160cda.

⛔ Files ignored due to path filters (1)
  • packages/evlog/test/toolkit/__snapshots__/api-surface.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (5)
  • .changeset/hono-use-logger.md
  • AGENTS.md
  • apps/docs/content/4.integrate/frameworks/08.hono.md
  • packages/evlog/src/hono/index.ts
  • packages/evlog/test/frameworks/hono.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@HugoRCD

HugoRCD commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@HugoRCD

HugoRCD commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Base automatically changed from fix/waituntil-propagation to main August 1, 2026 16:07
Hono was the only framework integration without `useLogger()`, so reaching
the request logger from a service or repository meant threading the Hono
`Context` down through every call. It now uses `createLoggerStorage()` like
every other integration and runs the downstream handler inside the storage.

`c.get('log')` is unchanged and stays the idiomatic accessor inside route
handlers — the two return the same logger. Attaching AsyncLocalStorage also
enables `log.fork()`, which Hono previously lacked (the docs called this
out).

Tradeoff: `evlog/hono` now imports `node:async_hooks` transitively via
`evlog/toolkit/storage`, so Cloudflare Workers deployments need the
`nodejs_compat` / `nodejs_als` flag. Documented on the Hono page and in the
changeset. `evlog/workers` is unaffected and stays async_hooks-free.

Updates AGENTS.md: the Hono carve-out is replaced by the general contract
every integration is now expected to satisfy.
@pkg-pr-new

pkg-pr-new Bot commented Aug 1, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@evlog/cli@476
npm i https://pkg.pr.new/evlog@476
npm i https://pkg.pr.new/@evlog/nuxthub@476
npm i https://pkg.pr.new/@evlog/telemetry@476

commit: 1160cda

@HugoRCD

HugoRCD commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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