Skip to content

feat: add slf4j structured logging with secret redaction#73

Merged
mogita merged 4 commits into
mainfrom
feat/cha-2957-logging
Jul 22, 2026
Merged

feat: add slf4j structured logging with secret redaction#73
mogita merged 4 commits into
mainfrom
feat/cha-2957-logging

Conversation

@mogita

@mogita mogita commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Ticket

https://linear.app/stream/issue/CHA-2957/logging

Summary

Adds SLF4J structured logging via StreamClientOptions.setLogger(...): client.initialized, http.request.sent, http.response.received, http.request.failed. Mandatory redaction of secret query params and known-secret body keys. Opt-in setLogBodies with a one-shot WARN. Adds org.slf4j:slf4j-api. The deprecated HttpLoggingInterceptor now redacts secret headers and URL query values.

Scope note (framework only)

The generated services/*Impl.java still use the retained 8-arg StreamRequest constructor (no-op logger), so events fire only once a follow-up spec-sync regeneration switches them to the new client-passing constructor. This PR is non-breaking: the old constructor is retained.

Tests

LoggingTest green; spotlessCheck clean.

mogita added 3 commits July 22, 2026 15:09
…logging tests

Fix 1 (critical): the deprecated HttpLoggingInterceptor logged request.url()
and response.request().url() verbatim. The auth interceptor appends api_key
downstream, so the response-summary line printed the live key at any level >=
BASIC. Add LogRedaction.redactUrl and route both URL log sites through it.

Fix 2: the queryRedaction test passed a null query, so redactQuery
short-circuited on querySize()==0 and never ran. Drive a request whose built
URL carries token=SECRET and assert url.query shows token=<redacted>.

Fix 3: setBaseUrl was public only for tests. Make it package-private and
relocate LoggingTest into io.getstream.services.framework so it is off the
public API.

Fix 4: assert all 9 client.initialized schema fields, not just 2.
@mogita
mogita merged commit 88ad7c9 into main Jul 22, 2026
4 checks passed
@mogita
mogita deleted the feat/cha-2957-logging branch July 22, 2026 17:25
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