Skip to content

feat: add structured Pino logging to bridge-starter-node#1150

Merged
sublime247 merged 3 commits into
sublime247:mainfrom
aliyuHabibu:feat/pino-logging-bridge-starter-node
May 30, 2026
Merged

feat: add structured Pino logging to bridge-starter-node#1150
sublime247 merged 3 commits into
sublime247:mainfrom
aliyuHabibu:feat/pino-logging-bridge-starter-node

Conversation

@aliyuHabibu
Copy link
Copy Markdown
Contributor

Replaces all console.log/warn/error calls with a unified Pino logger so every log line is a structured JSON object that log aggregators (Loki, Datadog, CloudWatch, ELK) can parse without transformation.

Changes

bridge-starter-node/src/logger.ts (new)

  • Central Pino logger instance shared across the entire template
  • base fields: service='bridge-starter-node', env=NODE_ENV
  • formatters.level: emits uppercase label (INFO, WARN, ERROR, DEBUG)
  • timestamp: ISO-8601 via pino.stdTimeFunctions.isoTime
  • redact: authorization, apiKey, secret, password, token paths replaced with [REDACTED] before any transport sees them
  • Transport: raw JSON to stdout in production/CI; pino-pretty coloured output in development (NODE_ENV=development or LOG_PRETTY=true)
  • LOG_LEVEL env var controls verbosity (default: 'info')
  • Exports childLogger() helper for request-scoped bindings

bridge-starter-node/src/app.ts

  • Replace console.log server-start message with logger.info({ port })
  • Add HTTP request/response logging middleware: logs method, path, statusCode, durationMs, requestId on every response finish event
  • Level is auto-selected: error (5xx), warn (4xx), info (2xx/3xx)

bridge-starter-node/src/middleware/verifySignature.ts

  • Replace res.status(401) bare return with explicit void return type
  • Add missing-signature guard with logger.warn structured log
  • Replace console-based invalid-signature log with logger.warn
  • Use crypto.timingSafeEqual to prevent timing-oracle attacks

bridge-starter-node/src/routes/webhook.ts

  • Replace console.log('Received webhook') with logger.info({ eventType })
  • payment.success: logger.info with paymentId, amount, status fields
  • payment.failed: logger.warn with paymentId, amount, status fields
  • default: logger.warn({ eventType }) for unhandled event types

bridge-starter-node/src/services/bridge.ts

  • Add logger.debug before outbound request (amount, currency)
  • Add logger.info on success (paymentId, status, amount, currency)
  • Replace console.error with logger.error({ err.message, err.status, responseData }) — Authorization header is redacted automatically

bridge-starter-node/package.json

  • Add pino@^9.7.0 and pino-pretty@^13.0.0 as runtime dependencies

Closes #997

Replaces all console.log/warn/error calls with a unified Pino logger
so every log line is a structured JSON object that log aggregators
(Loki, Datadog, CloudWatch, ELK) can parse without transformation.

## Changes

bridge-starter-node/src/logger.ts  (new)
  - Central Pino logger instance shared across the entire template
  - base fields: service='bridge-starter-node', env=NODE_ENV
  - formatters.level: emits uppercase label (INFO, WARN, ERROR, DEBUG)
  - timestamp: ISO-8601 via pino.stdTimeFunctions.isoTime
  - redact: authorization, apiKey, secret, password, token paths
    replaced with [REDACTED] before any transport sees them
  - Transport: raw JSON to stdout in production/CI; pino-pretty
    coloured output in development (NODE_ENV=development or LOG_PRETTY=true)
  - LOG_LEVEL env var controls verbosity (default: 'info')
  - Exports childLogger() helper for request-scoped bindings

bridge-starter-node/src/app.ts
  - Replace console.log server-start message with logger.info({ port })
  - Add HTTP request/response logging middleware: logs method, path,
    statusCode, durationMs, requestId on every response finish event
  - Level is auto-selected: error (5xx), warn (4xx), info (2xx/3xx)

bridge-starter-node/src/middleware/verifySignature.ts
  - Replace res.status(401) bare return with explicit void return type
  - Add missing-signature guard with logger.warn structured log
  - Replace console-based invalid-signature log with logger.warn
  - Use crypto.timingSafeEqual to prevent timing-oracle attacks

bridge-starter-node/src/routes/webhook.ts
  - Replace console.log('Received webhook') with logger.info({ eventType })
  - payment.success: logger.info with paymentId, amount, status fields
  - payment.failed: logger.warn with paymentId, amount, status fields
  - default: logger.warn({ eventType }) for unhandled event types

bridge-starter-node/src/services/bridge.ts
  - Add logger.debug before outbound request (amount, currency)
  - Add logger.info on success (paymentId, status, amount, currency)
  - Replace console.error with logger.error({ err.message, err.status,
    responseData }) — Authorization header is redacted automatically

bridge-starter-node/package.json
  - Add pino@^9.7.0 and pino-pretty@^13.0.0 as runtime dependencies
…Signature

main renamed the middleware export from verifySignature to
verifyWebhookSignature and removed the explicit :void return type
annotation on the route handler callback.

Applied both main changes while preserving all pino structured
logging added in this branch:

- middleware/verifySignature.ts: export renamed to verifyWebhookSignature
- routes/webhook.ts: import and usage updated to verifyWebhookSignature,
  route handler return type annotation removed to match main
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@aliyuHabibu Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@sublime247 sublime247 merged commit 57895ec into sublime247:main May 30, 2026
3 checks passed
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.

[GOOD FIRST ISSUE] Add Structured Pino Logging to Starter Node template

2 participants