Skip to content

feat: add HTTP request logger using undici Dispatcher#79

Merged
lollipop-onl merged 12 commits into
mainfrom
feat/undici-http-logger
Mar 12, 2026
Merged

feat: add HTTP request logger using undici Dispatcher#79
lollipop-onl merged 12 commits into
mainfrom
feat/undici-http-logger

Conversation

@lollipop-onl
Copy link
Copy Markdown
Collaborator

@lollipop-onl lollipop-onl commented Mar 12, 2026

Summary

  • Add an HTTP request logger using undici's Dispatcher.compose interceptor
  • Logs request start/end via consola.debug — visible only with CONSOLA_LEVEL=4 or higher
  • Masks apiKey query parameter automatically in log output
  • Decodes percent-encoded query parameters for readability
  • Shows API host once on the first request, then logs path-only for subsequent requests

Log output example

⚙ API host: https://example.backlog.com
⚙ → GET /api/v2/space/activities?apiKey=***
⚙ ← 200 GET /api/v2/space/activities?apiKey=*** (279ms)
⚙ → GET /api/v2/notifications?apiKey=***
⚙ ← 200 GET /api/v2/notifications?apiKey=*** (712ms)

Breaking Changes

  • Minimum Node.js version bumped from >=20 to >=20.18 (required for undici Dispatcher.compose support)

Test plan

  • 7 unit tests in http-logger.test.ts pass
  • All 712 existing tests pass (no regressions)
  • Manual verification with CONSOLA_LEVEL=5 bee space activities --space simochee.backlog.com
  • Manual verification with bee notification list — apiKey masked correctly
  • Error logging verified with connection failure scenario

🤖 Generated with Claude Code

lollipop-onl and others added 9 commits March 12, 2026 12:16
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Create a logging interceptor using undici's Dispatcher.compose that logs
HTTP request start/end via consola.debug, with timing information.
Includes undici dependency and comprehensive tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace Proxy-based handler wrapping with plain delegate object using
the v7 dispatch handler API (onResponseStart/onResponseError instead
of onHeaders/onError). This avoids TypeError when undici's WrapHandler
tries to access private #handler field through a Proxy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Show API host once on first request instead of repeating in every line
- Remove [backlog] prefix for cleaner output
- Decode percent-encoded query parameters for readability
- Show path only (without origin) in per-request logs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 12, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 92.12% 1824 / 1980
🔵 Statements 92.21% 1896 / 2056
🔵 Functions 90.18% 395 / 438
🔵 Branches 78.55% 813 / 1035
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/backlog-utils/src/http-logger.ts 84.37% 70% 66.66% 83.87% 15, 43-46, 54-57
Generated in workflow #390 for commit 1da9511 by the Vitest Coverage Report Action

lollipop-onl and others added 3 commits March 12, 2026 14:43
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use `tsx --env-file=.env.development` instead of `cross-env` for
cross-platform dev script. Also remove duplicate undici entry from
backlog-utils devDependencies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lollipop-onl lollipop-onl merged commit 9346174 into main Mar 12, 2026
7 checks passed
@lollipop-onl lollipop-onl deleted the feat/undici-http-logger branch March 12, 2026 05:50
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