/**
 * Global Logger Registry for Agent SDK
 *
 * Provides zero-overhead logging access for utility functions and services
 * without requiring parameter passing. Maintains singleton logger instance
 * accessible across all SDK modules.
 *
 * Features:
 * - Zero overhead when no logger configured (single null check)
 * - Thread-safe in Node.js single-threaded environment
 * - Maintains backward compatibility with existing Logger interface
 * - Direct function delegation when configured
 */
/**
 * Module-level storage for the global logger instance
 * null = unconfigured (logging calls are no-ops)
 * Logger = configured (calls are forwarded)
 */
let globalLogger = null;
// =============================================================================
// Registry Management API
// =============================================================================
/**
 * Configure the global logger instance used by utility functions and services
 *
 * @param logger - Logger instance implementing the Logger interface, or null to disable logging
 * @returns void
 *
 * @example
 * ```typescript
 * import { setGlobalLogger } from './utils/globalLogger.js';
 *
 * // Configure logger
 * setGlobalLogger(myLogger);
 *
 * // Disable logging
 * setGlobalLogger(null);
 * ```
 */
export function setGlobalLogger(logger) {
    globalLogger = logger;
}
/**
 * Reset global logger to unconfigured state
 * Equivalent to setGlobalLogger(null)
 *
 * @example
 * ```typescript
 * clearGlobalLogger(); // All subsequent logging calls become no-ops
 * ```
 */
export function clearGlobalLogger() {
    globalLogger = null;
}
/**
 * Check if global logger is currently configured
 *
 * @returns true if logger configured, false otherwise
 *
 * @example
 * ```typescript
 * if (isLoggerConfigured()) {
 *   // Perform expensive logging operation
 *   const debugInfo = generateDebugInfo();
 *   logger.debug(debugInfo);
 * }
 * ```
 */
export function isLoggerConfigured() {
    return globalLogger !== null;
}
// =============================================================================
// Zero-Overhead Logging API
// =============================================================================
/**
 * Zero-overhead logging interface
 *
 * Performance characteristics:
 * - Unconfigured: Single null check + early return (near-zero cost)
 * - Configured: Null check + function delegation
 * - No object creation or intermediate allocations
 */
export const logger = {
    /**
     * Log debug-level message through global logger
     * No-op when global logger is null (zero overhead)
     */
    debug: (...args) => {
        if (globalLogger === null)
            return;
        globalLogger.debug(...args);
    },
    /**
     * Log info-level message through global logger
     * No-op when global logger is null (zero overhead)
     */
    info: (...args) => {
        if (globalLogger === null)
            return;
        globalLogger.info(...args);
    },
    /**
     * Log warning-level message through global logger
     * No-op when global logger is null (zero overhead)
     */
    warn: (...args) => {
        if (globalLogger === null)
            return;
        globalLogger.warn(...args);
    },
    /**
     * Log error-level message through global logger
     * No-op when global logger is null (zero overhead)
     */
    error: (...args) => {
        if (globalLogger === null)
            return;
        globalLogger.error(...args);
    },
};
