// src/utils/logger.ts
import fs from "fs";
var Logger = {
  isHTTP: false,
  log: (...args) => {
    if (Logger.isHTTP) {
      console.log("[INFO-HTTP]", ...args);
    } else {
      console.log("[INFO-NO-HTTP]", ...args);
    }
  },
  logA: (...args) => {
    if (Logger.isHTTP) {
      console.log("[INFO-HTTP]", ...args);
    } else {
      console.log("[INFO-NO-HTTP]", ...args);
    }
  },
  logB: (...args) => {
    if (Logger.isHTTP) {
      console.log("[INFO-HTTP]", ...args);
    } else {
      console.log("[INFO-NO-HTTP]", ...args);
    }
  },
  error: (...args) => {
    console.log("[ERROR]", ...args);
  }
};
function writeLogs(name, value) {
  try {
    const logsDir = "logs";
    const logPath = `${logsDir}/${name}`;
    fs.accessSync(process.cwd(), fs.constants.W_OK);
    if (!fs.existsSync(logsDir)) {
      fs.mkdirSync(logsDir, { recursive: true });
    }
    fs.writeFileSync(logPath, JSON.stringify(value, null, 2));
  } catch (error) {
    const errorMessage = error instanceof Error ? error.message : String(error);
    Logger.logA(`Failed to write logs to ${name}: ${errorMessage}`);
  }
}

export {
  Logger,
  writeLogs
};
