Logging

Every backend SDK emits structured logs so you can trace requests, debug failures, and feed the events into your observability stack. Logging is opt-in: attach a logger when you build the client and the SDK emits a small, fixed set of events with the same field names across every language.

Enabling logging

Pass a logger when you construct the client. The SDK writes to it directly and never changes its level, so you control verbosity and destination through your own logging setup. Request and response events are emitted at DEBUG, the initialization event at INFO, and transport failures at ERROR, so set your logger to DEBUG to see per-request activity.

import (
    "log"
    "os"

    stream "github.com/GetStream/getstream-go/v4"
)

logger := stream.NewDefaultLogger(os.Stderr, "", log.LstdFlags, stream.LogLevelDebug)

client, err := stream.NewClient("your_api_key", "your_api_secret",
    stream.WithLogger(logger),
    stream.WithLogBodies(false), // opt-in; set true to also log redacted request/response bodies
)

Log events

The SDK emits four events, identical across languages. Each carries the same set of fields regardless of the SDK you use.

EventLevelWhen
client.initializedINFOOnce, when the client is constructed.
http.request.sentDEBUGBefore each HTTP request.
http.response.receivedDEBUGAfter each response, including 4xx and 5xx.
http.request.failedERROR / DEBUGERROR on a transport failure with no HTTP response; DEBUG for each attempt about to be retried.

Fields

The client.initialized event describes the client: stream.sdk.name and stream.sdk.version, plus the effective configuration under stream.client.* (connection-pool and timeout settings, and whether body logging is on).

The http.* events use OpenTelemetry-style keys: http.request.method, url.path, url.query, http.response.status_code, http.response.body.size, and duration_ms. On http.request.failed, error.message is always present and error.type is set for transport failures only (one of connection_reset, timeout, dns_failure, tls_handshake_failed, unknown). When an attempt is retried, retry.attempt records the attempt number.

Redaction

Redaction is always on and cannot be disabled. The SDK never logs header values, so your API secret and auth tokens never appear in logs. It also replaces sensitive query parameters (api_key, api_secret, token) and known-secret body fields (api_secret, token, password) with <redacted>.

Logging request and response bodies

Request and response bodies are not logged by default. You can opt in with the body-logging flag shown above for deep debugging. Bodies stay key-redacted, but they can still contain message content or user PII, so keep this disabled in production. Enabling it logs a one-time warning at construction as a reminder.