import { diag, DiagLogLevel } from "@opentelemetry/api";
function getOtelLogLevel(level) {
  if (!level) return void 0;
  const normalizedLevel = level.toLowerCase();
  switch (normalizedLevel) {
    case "none":
      return DiagLogLevel.NONE;
    case "error":
      return DiagLogLevel.ERROR;
    case "warn":
    case "warning":
      return DiagLogLevel.WARN;
    case "info":
      return DiagLogLevel.INFO;
    case "debug":
      return DiagLogLevel.DEBUG;
    case "verbose":
      return DiagLogLevel.VERBOSE;
    case "all":
      return DiagLogLevel.ALL;
    default:
      return void 0;
  }
}
let diagLoggerConfigured = false;
function setupOtelDiagnosticLogger(lc, force = false) {
  if (!lc) {
    return false;
  }
  if (!force && diagLoggerConfigured) {
    return false;
  }
  const log = lc.withContext("component", "otel");
  diag.setLogger(
    {
      verbose: (msg, ...args) => log.debug?.(msg, ...args),
      debug: (msg, ...args) => log.debug?.(msg, ...args),
      info: (msg, ...args) => log.info?.(msg, ...args),
      warn: (msg, ...args) => log.warn?.(msg, ...args),
      error: (msg, ...args) => log.warn?.(msg, ...args)
    },
    {
      logLevel: getOtelLogLevel(process.env.OTEL_LOG_LEVEL) ?? DiagLogLevel.ERROR,
      suppressOverrideMessage: true
    }
  );
  diagLoggerConfigured = true;
  return true;
}
export {
  setupOtelDiagnosticLogger
};
//# sourceMappingURL=otel-diag-logger.js.map
