For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
        • AuthHandler
        • ConfigLoader
        • Environment Variables
        • Logging
        • PromptManager
        • SchemaUtils
        • ServerlessAdapter
        • SessionManager
        • SslConfig
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Logger
  • Parameters
  • debug / info / warn / error
  • bind
  • getLogger
  • Parameters
  • Returns
  • Example
  • setGlobalLogLevel
  • Parameters
  • Returns
  • Example
  • suppressAllLogs
  • Parameters
  • Returns
  • Example
  • setGlobalLogFormat
  • Parameters
  • Returns
  • Example
  • setGlobalLogColor
  • Parameters
  • Returns
  • Example
  • setGlobalLogStream
  • Parameters
  • Returns
  • Example
  • resetLoggingConfiguration
  • Parameters
  • Returns
  • Example
  • getExecutionMode
  • Parameters
  • Returns
  • Example
AgentsConfiguration

Logging

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

PromptManager

Next
Built with

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.

1import { Logger, getLogger, setGlobalLogLevel } from '@signalwire/sdk';

Logger

Structured logger that respects global level, format, and color settings. Each Logger has a name and optional bound context data included in every entry.

Parameters

name
stringRequired

Logger name shown in log output (e.g., "AgentBase", "SessionManager").

context
Record<string, unknown>

Optional key-value pairs included in every log entry from this logger.

debug / info / warn / error

Log a message at the given severity level.

msg
stringRequired

The log message.

data
Record<string, unknown>

Optional structured data to include in the log entry.

bind

Create a child logger with additional bound context fields merged into the parent’s context.

context
Record<string, unknown>Required

Key-value pairs to merge into the child logger’s context.

Returns: Logger — A new Logger instance with the merged context.


getLogger

Create or retrieve a cached Logger instance by name.

Parameters

name
stringRequired

Logger name. Instances are cached — calling getLogger('foo') twice returns the same Logger.

Returns

Logger

Example

1import { getLogger } from '@signalwire/sdk';
2
3const log = getLogger('MyAgent');
4log.info('Agent started', { port: 3000 });
5log.debug('Processing request', { callId: 'abc-123' });

setGlobalLogLevel

Set the minimum log level for all loggers. Messages below this level are suppressed.

Parameters

level
"debug" | "info" | "warn" | "error"Required

The minimum severity level to emit.

Returns

void

Example

1import { setGlobalLogLevel } from '@signalwire/sdk';
2
3setGlobalLogLevel('debug'); // Show all messages including debug

suppressAllLogs

Suppress or restore all log output globally.

Parameters

suppress
booleanDefaults to true

true to suppress all output, false to restore.

Returns

void

Example

1import { suppressAllLogs } from '@signalwire/sdk';
2
3suppressAllLogs(true); // Silence all logging

setGlobalLogFormat

Set the output format for all loggers.

Parameters

format
"text" | "json"Required

"text" for human-readable output with colors, "json" for structured JSON entries.

Returns

void

Example

1import { setGlobalLogFormat } from '@signalwire/sdk';
2
3setGlobalLogFormat('json'); // Structured JSON output for log aggregators

setGlobalLogColor

Enable or disable ANSI color codes in text-format output.

Parameters

enabled
booleanRequired

true to enable colors, false to disable.

Returns

void

Example

1import { setGlobalLogColor } from '@signalwire/sdk';
2
3setGlobalLogColor(false); // Disable colors for CI/CD pipelines

setGlobalLogStream

Set the output stream for all loggers.

Parameters

stream
"stdout" | "stderr"Required

The output stream to use.

Returns

void

Example

1import { setGlobalLogStream } from '@signalwire/sdk';
2
3setGlobalLogStream('stderr'); // Route all logs to stderr

resetLoggingConfiguration

Reset all logging settings to their environment-variable-based defaults and clear the logger cache.

Parameters

None.

Returns

void

Example

1import { resetLoggingConfiguration } from '@signalwire/sdk';
2
3resetLoggingConfiguration();

getExecutionMode

Detect the execution environment by inspecting well-known environment variables.

Parameters

None.

Returns

[string, 'off' | 'stderr' | 'default'] — A tuple of [environment_name, derived_log_mode].

EnvironmentDetectionLog Mode
CGIGATEWAY_INTERFACEoff
AWS LambdaAWS_LAMBDA_FUNCTION_NAME or LAMBDA_TASK_ROOTstderr
Google Cloud FunctionsFUNCTION_TARGET or K_SERVICEdefault
Azure FunctionsAZURE_FUNCTIONS_ENVIRONMENT or FUNCTIONS_WORKER_RUNTIMEdefault
Server (default)No matchdefault

Example

1import { getExecutionMode } from '@signalwire/sdk';
2
3const [env, mode] = getExecutionMode();
4console.log(`Running in ${env} environment (log mode: ${mode})`);