kinetex - v1.0.0-rc.1
    Preparing search index...

    Class HTTPLogger

    Structured HTTP request/response/error logger. Supports multiple transports, redaction, sampling, filtering, and child loggers.

    Index

    Constructors

    Methods

    • Log an outgoing HTTP request.

      Parameters

      • requestId: string

        Correlated request identifier

      • method: string

        HTTP method

      • url: string

        Request URL

      • headers: Record<string, string>

        Request headers (sensitive values are redacted)

      • body: string | Uint8Array<ArrayBufferLike> | null

        Request body (redacted/truncated)

      • attempt: number

        Retry attempt number

      • meta: Record<string, unknown> = {}

        Arbitrary metadata

      Returns void

    • Log an HTTP response.

      Parameters

      • requestId: string

        Correlated request identifier

      • status: number

        HTTP status code

      • statusText: string

        HTTP status text

      • headers: Record<string, string>

        Response headers (sensitive values are redacted)

      • body: string | Uint8Array<ArrayBufferLike> | null

        Response body (redacted/truncated)

      • attempt: number

        Retry attempt number

      • cached: boolean

        Whether the response was served from cache

      • meta: Record<string, unknown> = {}

        Arbitrary metadata

      Returns void

    • Log an HTTP error.

      Parameters

      • requestId: string

        Correlated request identifier

      • error: unknown

        The error object

      • status: number | null

        HTTP status code, or null if no response

      • attempt: number

        Retry attempt number

      • meta: Record<string, unknown> = {}

        Arbitrary metadata

      Returns void

    • Generate a unique request ID using the configured generator.

      Returns string

    • Create a child logger with additional context fields.

      The child logger inherits all configuration from the parent (transports, redaction, etc.) but adds or overrides the context object with additional fields.

      Note: Context is copied, not shared. Changes to the parent context after creating a child do not affect the child, and vice versa.

      Parameters

      • context: Record<string, unknown>

        Additional context fields to merge into the logger's context

      Returns HTTPLogger

      A new HTTPLogger with merged context

      const logger = createProductionLogger();
      const child = logger.child({ requestId: "req-123", userId: "user-456" });
      child.logRequest(...); // Logs will include both requestId and userId
    • Flush all buffered log entries to their transports. Errors in individual transports are settled independently.

      Returns Promise<void>