// src/server/utils/logger.ts
var LEVELS = {
  debug: 0,
  info: 1,
  warn: 2,
  error: 3
};
var currentLevel = "info";
function setLogLevel(level, mode) {
  if (mode && !level) {
    currentLevel = mode === "development" ? "debug" : mode === "test" ? "error" : "warn";
  } else {
    currentLevel = level ?? "info";
  }
}
function shouldLog(level) {
  return LEVELS[level] >= LEVELS[currentLevel];
}
function formatMessage(level, message, context) {
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
  const prefix = `[${timestamp}] [${level.toUpperCase()}]`;
  if (context && Object.keys(context).length > 0) {
    return `${prefix} ${message} ${JSON.stringify(context)}`;
  }
  return `${prefix} ${message}`;
}
var logger = {
  debug(message, context) {
    if (shouldLog("debug")) {
      console.debug(formatMessage("debug", message, context));
    }
  },
  info(message, context) {
    if (shouldLog("info")) {
      console.info(formatMessage("info", message, context));
    }
  },
  warn(message, context) {
    if (shouldLog("warn")) {
      console.warn(formatMessage("warn", message, context));
    }
  },
  error(message, context) {
    if (shouldLog("error")) {
      console.error(formatMessage("error", message, context));
    }
  }
};

export {
  setLogLevel,
  logger
};
//# sourceMappingURL=chunk-K44MW7JJ.js.map