/**
 * Simple logger utility — wraps console with consistent formatting
 */

const ts = () => new Date().toISOString();

export const logger = {
  debug: (msg: string, ctx?: Record<string, unknown>) => {
    if (process.env.LOG_LEVEL === "debug") {
      console.debug(`[DEBUG] ${ts()} ${msg}`, ctx ?? "");
    }
  },
  info: (msg: string, ctx?: Record<string, unknown>) => {
    console.log(`[INFO]  ${ts()} ${msg}`, ctx ?? "");
  },
  warn: (msg: string, ctx?: Record<string, unknown>) => {
    console.warn(`[WARN]  ${ts()} ${msg}`, ctx ?? "");
  },
  error: (msg: string, ctx?: Record<string, unknown>) => {
    console.error(`[ERROR] ${ts()} ${msg}`, ctx ?? "");
  },
};
