import chalk from 'chalk'; type LogLevel = 'debug' | 'info' | 'warn' | 'error'; const LOG_LEVELS: Record = { debug: 0, info: 1, warn: 2, error: 3, }; let currentLevel: LogLevel = 'info'; export function setLogLevel(level: LogLevel): void { currentLevel = level; } export function getLogLevel(): LogLevel { return currentLevel; } function shouldLog(level: LogLevel): boolean { return LOG_LEVELS[level] >= LOG_LEVELS[currentLevel]; } export function debug(message: string, ...args: unknown[]): void { if (shouldLog('debug')) { console.log(chalk.gray(`[DEBUG] ${message}`), ...args); } } export function info(message: string, ...args: unknown[]): void { if (shouldLog('info')) { console.log(chalk.blue(`[INFO] ${message}`), ...args); } } export function warn(message: string, ...args: unknown[]): void { if (shouldLog('warn')) { console.log(chalk.yellow(`[WARN] ${message}`), ...args); } } export function error(message: string, ...args: unknown[]): void { if (shouldLog('error')) { console.error(chalk.red(`[ERROR] ${message}`), ...args); } } export function success(message: string, ...args: unknown[]): void { console.log(chalk.green(message), ...args); } export function log(message: string, ...args: unknown[]): void { console.log(message, ...args); } export const logger = { debug, info, warn, error, success, log, setLevel: setLogLevel, getLevel: getLogLevel, };