/** * Configurable logger for SDK development tracing. * * Level taxonomy (single source of truth — every SDK file follows it): * - error: SDK or integrator-supplied input is broken (failed network with no * retry left, invalid identify input, storage write rejected, feature * crashed inside safewrap). * - warn: degraded but recovering (deprecated API, falling back from * localStorage to memory, retrying a failed request, ignoring an * unsupported config option, browser feature missing). * - info: one-time lifecycle events the integrator wants in the console * while wiring the SDK up (SDK initialised, autocapture started/stopped, * replay started/stopped, chat connected, person identified). * - debug: per-event trace useful when filing a bug (every captured event * name, every autocapture skip with reason, every queue flush, request * URLs, decide-endpoint payload). * * Default floor is 'warn' — so SDK errors and warnings always reach the * integrator without opt-in (matches Amplitude/PostHog/Sentry). Use 'none' * to silence everything (e.g. shared kiosk consoles). * * Resolution precedence for the active level: * 1. log_level / debug passed to vt.init() — locks the level. * 2. Remote config from /decide (diagnostics.defaultLogLevel) — applied only * if init did not lock the level. * 3. Module default 'warn'. */ import type { VTiltConfig } from "../types"; export type LogLevel = "none" | "error" | "warn" | "info" | "debug"; export interface Logger { /** * Set the active level. When `lockedByInit` is true the level is pinned * and subsequent calls to `setLevelFromRemote` are ignored. Use this * variant only from the init-config resolver in vtilt.ts. */ setLevel(level: LogLevel, lockedByInit?: boolean): void; /** * Apply a level coming from remote config. No-op when the integrator * pinned a level at init time, so a hard-coded snippet always wins. */ setLevelFromRemote(level: LogLevel | null | undefined): void; getLevel(): LogLevel; isLockedByInit(): boolean; debug(...args: unknown[]): void; info(...args: unknown[]): void; warn(...args: unknown[]): void; error(...args: unknown[]): void; } /** * Get the global SDK logger. Level is set by VTilt from config (log_level or * debug: true) and may later be overridden by remote config via * setLevelFromRemote — unless init pinned the level. */ export declare function getLogger(): Logger; /** * Resolve a log level from VTiltConfig. Centralises the * `log_level ?? (debug ? 'debug' : 'warn')` rule so call sites cannot drift. */ export declare function resolveLogLevel(config: Pick): LogLevel; /** * Apply a config-derived level to the global logger. Pass `lockedByInit` * (default true) when the call originates from vt.init() so remote config * cannot later override the integrator's choice. */ export declare function setLevelFromConfig(config: Pick, lockedByInit?: boolean): LogLevel; export declare function __resetLoggerForTests(): void;