Skip to content

feat(hono): add useLogger() middleware for route-scoped logger injection#4

Merged
gambonny merged 1 commit intomainfrom
feat/use-logger-middleware
May 19, 2025
Merged

feat(hono): add useLogger() middleware for route-scoped logger injection#4
gambonny merged 1 commit intomainfrom
feat/use-logger-middleware

Conversation

@gambonny
Copy link
Owner

This PR introduces a new Hono integration middleware useLogger() to simplify logger setup across routes using cflo.

  • Injects getLogger(route) into c.var, scoped to each request
  • Automatically enriches meta.route for all log calls
  • Does not override core logger behavior (info, debug, etc.)
  • Fully typed via DotSeparated
  • Optimized for ergonomics and consistency with Hono middleware conventions

Includes tests for:

  • Logger injection
  • Route-specific scope behavior
  • Structured JSON logging output

No breaking changes. All existing logger logic remains untouched.

@gambonny gambonny self-assigned this May 19, 2025
@gambonny gambonny added the enhancement New feature or request label May 19, 2025
@gambonny gambonny force-pushed the feat/use-logger-middleware branch from 60b76a6 to 12c2490 Compare May 19, 2025 20:23
@gambonny gambonny force-pushed the feat/use-logger-middleware branch from 12c2490 to e20fc1e Compare May 19, 2025 20:25
@gambonny gambonny merged commit 2485291 into main May 19, 2025
1 check failed
@gambonny gambonny deleted the feat/use-logger-middleware branch May 19, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant