Team Ai
Apppublic

Ratankumar10/code-execution-engine

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
logger.util.js52 linesDownload Raw Back to utils
1// ─── Logger Utility ──────────────────────────2// Lightweight colored logger — no external deps3 4const COLORS = {5  reset: "\x1b[0m",6  red: "\x1b[31m",7  green: "\x1b[32m",8  yellow: "\x1b[33m",9  blue: "\x1b[34m",10  magenta: "\x1b[35m",11  cyan: "\x1b[36m",12  gray: "\x1b[90m",13};14 15class Logger {16  _timestamp() {17    return new Date().toISOString();18  }19 20  info(...args) {21    console.log(22      `${COLORS.gray}[${this._timestamp()}]${COLORS.reset} ${COLORS.green}INFO ${COLORS.reset}`,23      ...args,24    );25  }26 27  warn(...args) {28    console.warn(29      `${COLORS.gray}[${this._timestamp()}]${COLORS.reset} ${COLORS.yellow}WARN ${COLORS.reset}`,30      ...args,31    );32  }33 34  error(...args) {35    console.error(36      `${COLORS.gray}[${this._timestamp()}]${COLORS.reset} ${COLORS.red}ERROR${COLORS.reset}`,37      ...args,38    );39  }40 41  debug(...args) {42    if (process.env.NODE_ENV === "development") {43      console.log(44        `${COLORS.gray}[${this._timestamp()}]${COLORS.reset} ${COLORS.cyan}DEBUG${COLORS.reset}`,45        ...args,46      );47    }48  }49}50 51module.exports = new Logger();52