/** * Logger adapter interface for structured logging in WebSocket routers. * * Allows applications to integrate their own logging solutions (Winston, Pino, * structured logging services) instead of console.log. * * @example * ```typescript * import { createRouter } from "@ws-kit/zod"; * import type { LoggerAdapter } from "@ws-kit/core"; * * // Custom logger implementation * class MyLogger implements LoggerAdapter { * debug(context: string, message: string, data?: unknown) { * console.debug(`[${context}] ${message}`, data); * } * * info(context: string, message: string, data?: unknown) { * console.log(`[${context}] ${message}`, data); * } * * warn(context: string, message: string, data?: unknown) { * console.warn(`[${context}] ${message}`, data); * } * * error(context: string, message: string, data?: unknown) { * console.error(`[${context}] ${message}`, data); * } * } * * const router = createRouter({ * logger: new MyLogger(), * }); * ``` */ export interface LoggerAdapter { /** * Log a debug-level message * * @param context - Category or source of the log (e.g., "connection", "heartbeat") * @param message - Log message * @param data - Optional structured data */ debug(context: string, message: string, data?: unknown): void; /** * Log an info-level message * * @param context - Category or source of the log * @param message - Log message * @param data - Optional structured data */ info(context: string, message: string, data?: unknown): void; /** * Log a warning-level message * * @param context - Category or source of the log * @param message - Log message * @param data - Optional structured data */ warn(context: string, message: string, data?: unknown): void; /** * Log an error-level message * * @param context - Category or source of the log * @param message - Log message * @param data - Optional structured data (error details, stack trace, etc.) */ error(context: string, message: string, data?: unknown): void; } /** * Default logger adapter that uses console methods * * @internal */ export declare class DefaultLoggerAdapter implements LoggerAdapter { debug(context: string, message: string, data?: unknown): void; info(context: string, message: string, data?: unknown): void; warn(context: string, message: string, data?: unknown): void; error(context: string, message: string, data?: unknown): void; } /** * Create a logger adapter that uses custom console methods * * @param options - Configuration options * @returns Logger instance * * @example * ```typescript * // Use custom console (e.g., structured logging service) * const logger = createConsoleLogger({ * log: (level, context, message, data) => { * // Send to logging service * logService.log({ * level, * context, * message, * data, * timestamp: new Date(), * }); * }, * }); * ``` */ export interface LoggerOptions { /** * Custom log function * * @param level - Log level (debug, info, warn, error) * @param context - Category or source * @param message - Message * @param data - Optional structured data */ log?: (level: "debug" | "info" | "warn" | "error", context: string, message: string, data?: unknown) => void; /** * Minimum log level to output (default: "debug") * - 0: debug * - 1: info * - 2: warn * - 3: error */ minLevel?: "debug" | "info" | "warn" | "error"; } /** * Create a logger adapter with custom configuration */ export declare function createLogger(options?: LoggerOptions): LoggerAdapter; /** * Log context constants used by ws-kit router * * Applications can use these to filter or categorize logs */ export declare const LOG_CONTEXT: { readonly CONNECTION: "connection"; readonly HEARTBEAT: "heartbeat"; readonly MESSAGE: "message"; readonly MIDDLEWARE: "middleware"; readonly AUTH: "auth"; readonly VALIDATION: "validation"; readonly ERROR: "error"; }; //# sourceMappingURL=logger.d.ts.map