// Logger with environment variable control // LOG_LEVEL: debug, info, warn, error, none (default: info) const LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3, none: 4 }; const currentLevel = LOG_LEVELS[process.env.LOG_LEVEL?.toLowerCase()] ?? LOG_LEVELS.info; const ts = () => new Date().toISOString(); const log = { debug: (...args) => currentLevel <= LOG_LEVELS.debug && console.log(`[${ts()}] [DEBUG]`, ...args), info: (...args) => currentLevel <= LOG_LEVELS.info && console.log(`[${ts()}] [INFO]`, ...args), warn: (...args) => currentLevel <= LOG_LEVELS.warn && console.warn(`[${ts()}] [WARN]`, ...args), error: (...args) => currentLevel <= LOG_LEVELS.error && console.error(`[${ts()}] [ERROR]`, ...args), }; module.exports = log;