Skip to content

refactor: add request context to logger - #452

Open
xabg2 wants to merge 6 commits into
masterfrom
refactor/structured-logger
Open

xabg2 wants to merge 6 commits into
masterfrom
refactor/structured-logger

Conversation

@xabg2

@xabg2 xabg2 commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

What's new

  • Every log line now says which service, environment and version wrote it.
  • Logs written while handling a request carry its request id, and logs written while handling a Stripe webhook also carry the event id and type, so everything that happened in one request or event can be found together.
  • Request ids are now unique across instances and deployments.
  • Stripe errors are logged with Stripe's request id, and the request body is no longer written to the error logs.

@xabg2 xabg2 added the enhancement New feature or request label Nov 18, 2026
@xabg2 xabg2 self-assigned this Nov 18, 2026
@xabg2 xabg2 added the enhancement New feature or request label Nov 18, 2026
Base automatically changed from refactor/remove-config-default to master November 19, 2026 09:32
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
54.9% Coverage on New Code (required ≥ 85%)

See analysis details on SonarQube Cloud

@xabg2
xabg2 marked this pull request as ready for review November 23, 2026 09:20
Comment thread src/Logger.ts
export const loggerOptions: LoggerOptions = {
level: env === 'test' ? 'silent' : process.env.LOG_LEVEL || 'info',
base: { service: 'payments', env, version },
redact: ['headers.authorization', 'token', 'captchaToken', 'confirmationTokenId', 'companyVatId'],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

companyVatId maybe good to be left as visible, it's something public on any company web page and we had issues in the past due to the format and validation, so it's good to see it on plain.

This branch was successfully deployed

1 active deployment
test — e93031c0 Deployed Nov 20, 2026 by xabg2 via Run tests (24.11.0) #1244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready-for-preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants