// src/log.ts
function formatArg(a) {
  if (typeof a === "string") return a;
  if (a instanceof Error) return a.stack ?? a.message;
  if (a === null || a === void 0) return String(a);
  if (typeof a === "object") {
    try {
      return JSON.stringify(a);
    } catch {
      return String(a);
    }
  }
  return String(a);
}
function write(stream, args) {
  try {
    if (!stream.writable) {
      process.exit(1);
    }
    const formatted = args.map(formatArg).join(" ");
    stream.write(formatted + "\n");
  } catch {
    process.exit(1);
  }
}
var safeLog = {
  error(...args) {
    write(process.stderr, args);
  },
  warn(...args) {
    write(process.stderr, args);
  }
};

export {
  safeLog
};
//# sourceMappingURL=chunk-CYDXIW4L.js.map