The SDK provides a structured logging system with configurable log levels, formats, colors, and output streams. Configuration is driven by environment variables (see Environment Variables) and can be overridden programmatically.
Structured logger that respects global level, format, and color settings. Each Logger has a name and optional bound context data included in every entry.
Logger name shown in log output (e.g., "AgentBase", "SessionManager").
Optional key-value pairs included in every log entry from this logger.
Log a message at the given severity level.
The log message.
Optional structured data to include in the log entry.
Create a child logger with additional bound context fields merged into the parent’s context.
Key-value pairs to merge into the child logger’s context.
Returns: Logger — A new Logger instance with the merged context.
Create or retrieve a cached Logger instance by name.
Logger name. Instances are cached — calling getLogger('foo') twice returns the same Logger.
Logger
Set the minimum log level for all loggers. Messages below this level are suppressed.
The minimum severity level to emit.
void
Suppress or restore all log output globally.
true to suppress all output, false to restore.
void
Set the output format for all loggers.
"text" for human-readable output with colors, "json" for structured JSON entries.
void
Enable or disable ANSI color codes in text-format output.
true to enable colors, false to disable.
void
Set the output stream for all loggers.
The output stream to use.
void
Reset all logging settings to their environment-variable-based defaults and clear the logger cache.
None.
void
Detect the execution environment by inspecting well-known environment variables.
None.
[string, 'off' | 'stderr' | 'default'] — A tuple of [environment_name, derived_log_mode].