Skip to content

feat!: unified pino logger replaces eventsLog and internalError - #65

Merged
albanm merged 12 commits into
mainfrom
feat-unified-logging
Oct 29, 2026
Merged

albanm merged 12 commits into
mainfrom
feat-unified-logging

Conversation

@albanm

@albanm albanm commented Oct 29, 2026

Copy link
Copy Markdown
Member

One logger for the whole stack in @data-fair/lib-node/log.js, replacing eventsLog, internalError and ad-hoc console output:

  • log.info|warn|alert|error(msg, { code?, err?, ... }): JSON lines on stdout when NODE_ENV=production, pretty otherwise (LOG_FORMAT overrides); alert is a custom level for events that deserve the scrutiny of errors
  • errors serialized with a whitelist (no headers, request config or document content), messages truncated to 1000 chars
  • warn/alert/error lines counted in df_logs{level, code, host}; df_internal_error and df_events_log still emitted, deprecated
  • implicit context with withLogContext / getLogContext (also for worker threads); session.middleware() opens it per request with ip, host, user and account
  • debug stays the debug API, its output is redirected into the logger
  • trace ids come from the OpenTelemetry operator's pino instrumentation, no OTel code in the lib
  • reqIp in optional mode flags a non-IP X-Forwarded-For and returns undefined instead of throwing

Why: uniform, structured output for everything (audit events, errors, debug) so logs can be filtered by host, account, level and code in Loki/VictoriaLogs and grouped by trace id, with minimal setup and no logger instances passed around.

Heads-up:

  • breaking: eventsLog, internalError and EVENTS_LOG_LEVEL removed; release lib-node as a major first, then bump lib-express's peer range to ^3.0.0 (and its README) before releasing it as a major
  • output format changes (no df-event: prefix, JSON on stdout): fluent-bit routes must be adapted before services upgrade
  • session.middleware() now passes session loading failures to next(err) instead of rejecting
  • info lines no longer increment df_events_log

albanm and others added 12 commits October 29, 2026 14:39
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BREAKING CHANGE: eventsLog (lib-express) and internalError (lib-node/observer)
are removed, use log from @data-fair/lib-node/log.js. Log output is now JSON
lines on stdout (pretty in dev), EVENTS_LOG_LEVEL is removed.
session.middleware() hands session loading failures to next(err) instead of
rejecting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- a malformed X-Forwarded-For no longer breaks requests through the session middleware
- error messages and stack headers are truncated to 1000 characters
- counters already registered by another copy of the module are reused
- an Error passed as the message is logged as err
- fields named like pino keys are renamed instead of duplicating them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uld fail loudly

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- reqIp in optional mode flags a non-IP X-Forwarded-For and returns undefined
  instead of throwing, strict mode still throws
- reserved pino keys and non-string messages are left to conventions and types
- the error serializer relies on its depth limit and on the logger's try/catch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@albanm
albanm merged commit 3085de4 into main Oct 29, 2026
@albanm
albanm deleted the feat-unified-logging branch October 29, 2026 15:16
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