Skip to content

feat: add structured pino logging#237

Open
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-37-structured-logging
Open

feat: add structured pino logging#237
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-37-structured-logging

Conversation

@pq198363-ops

Copy link
Copy Markdown

Closes #37.

Summary

  • add a shared pino-based src/logger.ts with LOG_LEVEL support
  • default logging to silent in NODE_ENV=test and info otherwise
  • redact API-key shaped fields including X-API-Key, apiKey, generated keys, and returned key values
  • replace request completion and shutdown console.* calls with structured logger helpers
  • keep request completion logs correlated with the existing X-Request-Id / req.id
  • document LOG_LEVEL in the README

RED evidence

Before implementation, npm run build failed because src/logger.test.ts imported missing pino and ./logger.js. The focused logger contract covered:

  • test-mode silence by default
  • log level filtering
  • API key and generated key redaction
  • request completion fields including requestId
  • shutdown error serialization without leaking key-shaped fields

Verification

  • npx prettier --check README.md package.json src/logger.ts src/logger.test.ts src/index.ts src/middleware/index.ts
  • npm run lint
  • npm run build
  • $env:NODE_ENV='test'; node --test dist/logger.test.js
  • clean dist/, then npm run build
  • $env:NODE_ENV='test'; node --test dist/*.test.js dist/**/*.test.js
  • git diff --check

Full clean test result: 94 tests, 11 suites, all passed.

Note: the package npm test script uses POSIX-style NODE_ENV=test; on Windows PowerShell I used the equivalent build plus node --test command above.

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.

Add structured logging with pino and per-request correlation context

1 participant