Skip to content

chore: migrate to pino 456 - #511

Merged
cameri merged 8 commits into
cameri:mainfrom
Priyanshubhartistm:migrate-to-pino-456
Apr 19, 2026
Merged

chore: migrate to pino 456#511
cameri merged 8 commits into
cameri:mainfrom
Priyanshubhartistm:migrate-to-pino-456

Conversation

@Priyanshubhartistm

Copy link
Copy Markdown
Collaborator

Description

This PR fully migrates the project's logging from the legacy debug module and direct console.log/console.error statements to Pino — a fast, structured logging library.

Key Changes:

  • Added pino (dependency) and pino-pretty (devDependency)
  • Created a new centralized logger at src/logger.ts with proper configuration (pretty output in development, structured JSON in production, controlled by LOG_LEVEL)
  • Refactored src/factories/logger-factory.ts to use Pino under the hood while preserving existing logger call patterns (logger.debug(), logger.info() etc.)
  • Migrated all logging call sites across the codebase (adapters, controllers, repositories, services, processors, database client, workers, etc.)
  • Replaced raw console.* calls with structured Pino logging for better observability
  • Removed the debug and @types/debug packages completely
  • Updated affected unit tests

Related Issue

Closes#456

Motivation and Context

Migrating to Pino improves:

  • Performance (much faster than debug)
  • Structured logging (better for production monitoring and log aggregation)
  • Developer experience with pretty, colored logs in development
  • Proper error object handling with stack traces

This change also brings the branch up to date with the latest main branch.

How Has This Been Tested?

  • Environment: Linux, Node.js v24.12.0
  • Ran the following commands:
    • npm run build:check
    • npm run lint
    • npm run test:unit -- --reporter dot
  • Results:
    • Build check passed
    • Linting passed
    • All 844 unit tests passed

No breaking changes to existing functionality. Logs now appear properly formatted when running the server locally.

Types of changes

  • Non-functional change (refactor / logging improvement)
  • Bug fix (minor fixes during rebase for logger stability)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • All new and existing tests passed.

@socket-security

socket-securityBot commented Apr 18, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

DiffPackageSupply Chain
Security
VulnerabilityQualityMaintenanceLicense
Addedpino-pretty@​13.1.39910010086100
Addedpino@​8.21.09810010090100

View full report

@coveralls

coveralls commented Apr 18, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 68.518% (+0.2%) from 68.308% — Priyanshubhartistm:migrate-to-pino-456 into cameri:main

@camericameri self-assigned this Apr 18, 2026
Comment threadsrc/app/app.ts
Comment threadsrc/factories/payments-processors/zebedee-payments-processor-factory.ts Outdated
Comment threadsrc/factories/logger-factory.ts
@PriyanshubhartistmPriyanshubhartistm changed the title Migrate to pino 456chore: migrate to pino 456Apr 18, 2026
@cameri
cameri requested a review from CopilotApril 18, 2026 23:54

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates runtime logging from debug/console.* to a centralized Pino-based logger, aiming to improve structured logging and observability across the app (workers, adapters, controllers, services, repositories, and utilities).

Changes:

  • Introduces a centralized src/logger.ts (Pino + dev pretty transport) and rewrites createLogger to wrap Pino while preserving existing logger() / logger.debug() call patterns.
  • Refactors log call sites across runtime code to use createLogger instead of debug/console.*, and adds/updates unit tests for the new logger factory behavior.
  • Updates tooling/deps (adds pino, pino-pretty, removes debug + typings; enforces Biome noConsole with targeted overrides) and includes a Changeset.

Reviewed changes

Copilot reviewed 59 out of 60 changed files in this pull request and generated 8 comments.

Show a summary per file
FileDescription
test/unit/utils/settings.spec.tsAdjusts unit expectations around settings creation behavior.
test/unit/services/payments-service.spec.tsUpdates unit tests impacted by logging refactor.
test/unit/services/maintenance-service.spec.tsRemoves console-stub assertions tied to old logging approach.
test/unit/factories/logger-factory.spec.tsAdds coverage for new Pino-backed createLogger wrapper behavior.
test/unit/app/maintenance-worker.spec.tsRemoves console-stub assertion in error-path test.
src/utils/sliding-window-rate-limiter.tsReplaces legacy debug logger usage with new logger wrapper.
src/utils/settings.tsReplaces debug/console calls with logger wrapper (including deprecation warning).
src/utils/nip05.tsMigrates NIP-05 verification logging to new logger wrapper.
src/utils/http.tsReplaces deprecation console.warn with logger wrapper.
src/tor/client.tsMigrates Tor client debug/console logs to new logger wrapper.
src/services/payments-service.tsMigrates service logging to new logger wrapper; replaces console.* usage.
src/services/maintenance-service.tsMigrates maintenance logging to logger wrapper.
src/repositories/user-repository.tsMigrates repository logging to logger wrapper and updates error logging.
src/repositories/nip05-verification-repository.tsMigrates repository logging to logger wrapper.
src/repositories/invoice-repository.tsMigrates repository logging to logger wrapper.
src/repositories/event-repository.tsMigrates repository logging to logger wrapper.
src/payments-processors/zebedee-payments-processor.tsMigrates processor logs to logger wrapper.
src/payments-processors/opennode-payments-processor.tsMigrates processor logs to logger wrapper.
src/payments-processors/nodeless-payments-processor.tsMigrates processor logs to logger wrapper.
src/payments-processors/lnurl-payments-processor.tsMigrates processor logs to logger wrapper.
src/payments-processors/lnbits-payment-processor.tsMigrates processor logs to logger wrapper.
src/logger.tsAdds centralized Pino instance + dev pretty transport configuration.
src/handlers/subscribe-message-handler.tsMigrates handler logging to logger wrapper.
src/handlers/request-handlers/rate-limiter-middleware.tsMigrates middleware logging to logger wrapper.
src/handlers/event-strategies/vanish-event-strategy.tsMigrates strategy logging to logger wrapper.
src/handlers/event-strategies/replaceable-event-strategy.tsMigrates strategy logging to logger wrapper.
src/handlers/event-strategies/parameterized-replaceable-event-strategy.tsMigrates strategy logging to logger wrapper.
src/handlers/event-strategies/gift-wrap-event-strategy.tsMigrates strategy logging to logger wrapper.
src/handlers/event-strategies/ephemeral-event-strategy.tsMigrates strategy logging to logger wrapper.
src/handlers/event-strategies/delete-event-strategy.tsMigrates strategy logging to logger wrapper.
src/handlers/event-strategies/default-event-strategy.tsMigrates strategy logging to logger wrapper.
src/handlers/event-message-handler.tsMigrates handler logging to logger wrapper and adds error logging on catch.
src/factories/worker-factory.tsReplaces console warnings with logger wrapper for deprecated settings.
src/factories/payments-processors/zebedee-payments-processor-factory.tsMigrates factory error logging to logger wrapper.
src/factories/payments-processors/opennode-payments-processor-factory.tsMigrates factory error logging to logger wrapper.
src/factories/payments-processors/nodeless-payments-processor-factory.tsMigrates factory error logging to logger wrapper.
src/factories/payments-processors/lnbits-payments-processor-factory.tsMigrates factory error logging to logger wrapper.
src/factories/payments-processor-factory.tsMigrates factory logging to logger wrapper.
src/factories/logger-factory.tsReplaces debug implementation with Pino-backed wrapper supporting formatting/child/extend.
src/database/client.tsReplaces pool monitor console.log and config debug logs with logger wrapper.
src/controllers/invoices/post-invoice-controller.tsMigrates controller logs to logger wrapper and cleans up error response formatting.
src/controllers/invoices/get-invoice-status-controller.tsMigrates controller logs to logger wrapper.
src/controllers/callbacks/zebedee-callback-controller.tsMigrates callback controller logs to logger wrapper.
src/controllers/callbacks/opennode-callback-controller.tsMigrates callback controller logs to logger wrapper.
src/controllers/callbacks/nodeless-callback-controller.tsMigrates callback controller logs to logger wrapper.
src/controllers/callbacks/lnbits-callback-controller.tsMigrates callback controller logs to logger wrapper.
src/controllers/admission/get-admission-check-controller.tsMigrates controller logs to logger wrapper.
src/cache/client.tsMigrates cache client config logging to logger wrapper.
src/app/worker.tsMigrates worker lifecycle/error logging to logger wrapper.
src/app/static-mirroring-worker.tsMigrates mirroring worker logs to logger wrapper.
src/app/maintenance-worker.tsMigrates maintenance worker logs to logger wrapper.
src/app/app.tsMigrates primary app startup/banner/lifecycle logs to logger wrapper.
src/adapters/web-socket-server-adapter.tsMigrates adapter logs to logger wrapper.
src/adapters/web-socket-adapter.tsMigrates adapter logs to logger wrapper.
src/adapters/web-server-adapter.tsMigrates adapter logs to logger wrapper.
src/adapters/redis-adapter.tsMigrates redis adapter logs to logger wrapper and updates error logging.
package.jsonAdds pino/pino-pretty and removes debug deps/types.
package-lock.jsonLocks new Pino dependencies and removes debug-related packages.
biome.jsonEnforces noConsole globally with overrides for scripts/migrations/tests.
.changeset/migrate-logging-to-pino.mdAdds a Changeset entry for the logging migration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadtest/unit/utils/settings.spec.ts
Comment threadsrc/tor/client.ts
Comment threadsrc/factories/logger-factory.ts
Comment threadsrc/factories/logger-factory.ts Outdated
Comment threadsrc/services/payments-service.ts
Comment threadsrc/services/payments-service.ts
Comment threadsrc/repositories/invoice-repository.ts
Comment threadtest/unit/services/payments-service.spec.ts Outdated
@Priyanshubhartistm
Priyanshubhartistm marked this pull request as draft April 19, 2026 00:04
@Priyanshubhartistm
Priyanshubhartistm marked this pull request as ready for review April 19, 2026 13:43
Sign up for freeto 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.

Migrate from debug/console to Pino

4 participants

@Priyanshubhartistm@coveralls@cameri