import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);

// src/logs/format.ts
var LOG_VALUE_MAX_DISPLAY = 80;
var CORE_FIELDS = ["timestamp", "level", "component", "message"];
function formatLogLine(entry) {
  const time = formatLocalTime(entry.timestamp);
  const lvl = entry.level.toUpperCase().padEnd(5);
  const comp = `[${entry.component}]`.padEnd(14);
  const extras = [];
  for (const [key, value] of Object.entries(entry)) {
    if (CORE_FIELDS.includes(key)) continue;
    const str = String(value);
    const display = str.length > LOG_VALUE_MAX_DISPLAY ? str.slice(0, LOG_VALUE_MAX_DISPLAY) + "..." : str;
    extras.push(`${key}=${display}`);
  }
  const extraStr = extras.length > 0 ? "  " + extras.join(" ") : "";
  return `${time} ${lvl} ${comp} ${entry.message}${extraStr}`;
}
function formatLocalTime(iso) {
  const d = new Date(iso);
  const hh = String(d.getHours()).padStart(2, "0");
  const mm = String(d.getMinutes()).padStart(2, "0");
  const ss = String(d.getSeconds()).padStart(2, "0");
  return `${hh}:${mm}:${ss}`;
}
function parseIntFlag(args, long, short) {
  for (let i = 0; i < args.length; i++) {
    if (args[i] === long || short && args[i] === short) {
      const val = parseInt(args[i + 1], 10);
      return isNaN(val) ? void 0 : val;
    }
  }
  return void 0;
}
function parseStringFlag(args, long, short) {
  for (let i = 0; i < args.length; i++) {
    if (args[i] === long || short && args[i] === short) {
      return args[i + 1];
    }
  }
  return void 0;
}

export {
  formatLogLine,
  parseIntFlag,
  parseStringFlag
};
//# sourceMappingURL=chunk-SAKJMNSR.js.map