/**
 * Main logging interface with facade pattern for backward compatibility
 * Uses dependency injection pattern to avoid circular dependencies.
 *
 * **Keep this barrel slim.** Previously it statically imported the entire
 * health-monitor, log-query, request-tracker, and performance subsystems
 * (~75 modules combined). None of those were used at runtime outside of
 * their own tests, but every `import {getLogger} from '../../utils/logging/index.js'`
 * was pulling them all into startup. Consumers that actually need those
 * subsystems should import them from their subpaths directly.
 */
import { getShutdownManager } from '../../utils/shutdown/index.js';
import { loggerProvider } from './logger-provider.js';
/**
 * Initialize the logger with configuration
 */
export function initializeLogger(config) {
    return loggerProvider.initializeLogger(config);
}
/**
 * Get the current logger instance
 */
export function getLogger() {
    return loggerProvider.getLogger();
}
/**
 * Get the current configuration
 */
export function getLoggerConfig() {
    return loggerProvider.getLoggerConfig();
}
/**
 * Create a child logger with additional context
 */
export function createChildLogger(bindings) {
    return loggerProvider.createChildLogger(bindings);
}
/**
 * Check if a log level is enabled
 */
export function isLevelEnabled(level) {
    return loggerProvider.isLevelEnabled(level);
}
/**
 * Convenience methods that match console.log API
 */
export const log = {
    fatal: (msg, ...args) => getLogger().fatal(msg, ...args),
    error: (msg, ...args) => getLogger().error(msg, ...args),
    warn: (msg, ...args) => getLogger().warn(msg, ...args),
    info: (msg, ...args) => getLogger().info(msg, ...args),
    http: (msg, ...args) => getLogger().http(msg, ...args),
    debug: (msg, ...args) => getLogger().debug(msg, ...args),
    trace: (msg, ...args) => getLogger().trace(msg, ...args),
};
/**
 * Backward compatibility facade - wraps console during transition
 * This will be gradually replaced with structured logging
 */
export const console = {
    log: (...args) => {
        // For now, use info level for console.log
        log.info(args.join(' '));
        if (process.env.NODE_ENV === 'development') {
            process.stderr.write('\x1b[33m[DEPRECATED]\x1b[0m console.log() is deprecated. Use logger.info() instead.\n');
        }
    },
    error: (...args) => {
        log.error(args.join(' '));
    },
    warn: (...args) => {
        log.warn(args.join(' '));
    },
    info: (...args) => {
        log.info(args.join(' '));
    },
    debug: (...args) => {
        log.debug(args.join(' '));
    },
};
/**
 * Flush any pending logs
 */
export async function flush() {
    await loggerProvider.flush();
}
/**
 * Flush logs synchronously (for signal handlers)
 */
function _flushSync() {
    loggerProvider.flushSync();
}
/**
 * End the logger and close all streams
 */
export async function end() {
    await loggerProvider.end();
}
// Register cleanup handlers with ShutdownManager.
//
// The health-monitor shutdown handler used to be registered here too, which
// forced a static import of the entire health-monitor subsystem at startup
// (~75 modules) for something that was never actually used at runtime.
// health-monitor is now internal-only — if it comes back as a feature,
// register its shutdown handler wherever it's instantiated.
const shutdownManager = getShutdownManager();
shutdownManager.register({
    name: 'logger',
    priority: 100,
    handler: async () => {
        await loggerProvider.flush();
        await loggerProvider.end();
    },
});
// Only the correlation helpers that are actually used outside the logging
// subsystem are re-exported from the barrel. Everything else (config utils,
// health-monitor, log-query, request-tracker, performance metrics) is
// available via its own subpath for specialized consumers — but no longer
// dragged into startup by every `getLogger()` caller.
export { generateCorrelationId, getCorrelationId, withNewCorrelationContext, } from './correlation.js';
//# sourceMappingURL=index.js.map