/** * Pluggable Logger Interface for A2A Edge Runtime * * Provides a minimal logging abstraction that works across all edge runtimes. * Users can implement this interface to integrate with their preferred logging solution. */ /** * Log levels supported by the A2A logger. */ type LogLevel = 'debug' | 'info' | 'warn' | 'error'; /** * Structured log context for additional metadata. */ /** * Error details in log context. */ interface LogContextError { name: string; message: string; stack?: string; code?: number; } interface LogContext { /** Request ID for tracing */ requestId?: string; /** Task ID being processed */ taskId?: string; /** HTTP method */ method?: string; /** Request path */ path?: string; /** HTTP status code */ statusCode?: number; /** Duration in milliseconds */ durationMs?: number; /** Error details */ error?: LogContextError; /** Additional custom fields */ [key: string]: unknown; } /** * Logger interface for A2A edge runtime. * * Implementations should be stateless and safe for concurrent use. * All methods are synchronous to avoid adding async overhead to hot paths. * * @example * ```ts * // Console logger (default) * const logger = ConsoleLogger.create(); * * // Custom structured logger * const logger: Logger = { * debug: (msg, ctx) => myLogger.debug({ ...ctx, message: msg }), * info: (msg, ctx) => myLogger.info({ ...ctx, message: msg }), * warn: (msg, ctx) => myLogger.warn({ ...ctx, message: msg }), * error: (msg, ctx) => myLogger.error({ ...ctx, message: msg }), * }; * ``` */ interface Logger { debug(message: string, context?: LogContext): void; info(message: string, context?: LogContext): void; warn(message: string, context?: LogContext): void; error(message: string, context?: LogContext): void; } /** * No-op logger that discards all log messages. * Useful for testing or when logging is not needed. */ declare const NoopLogger: Logger; /** * Console-based logger implementation. * Formats log messages with timestamp, level, and optional context. */ declare class ConsoleLogger implements Logger { private readonly minLevel; private static readonly LEVELS; constructor(minLevel?: LogLevel); /** * Creates a new ConsoleLogger instance. */ static create(minLevel?: LogLevel): Logger; private shouldLog; private formatMessage; debug(message: string, context?: LogContext): void; info(message: string, context?: LogContext): void; warn(message: string, context?: LogContext): void; error(message: string, context?: LogContext): void; } /** * JSON-structured logger for production environments. * Outputs newline-delimited JSON for easy parsing by log aggregators. */ declare class JsonLogger implements Logger { private readonly minLevel; private static readonly LEVELS; constructor(minLevel?: LogLevel); static create(minLevel?: LogLevel): Logger; private shouldLog; private log; debug(message: string, context?: LogContext): void; info(message: string, context?: LogContext): void; warn(message: string, context?: LogContext): void; error(message: string, context?: LogContext): void; } export { ConsoleLogger as C, JsonLogger as J, type Logger as L, NoopLogger as N, type LogContext as a, type LogLevel as b, type LogContextError as c };