/**
 * Lightweight logger wrapper
 * Replaces @extension/shared/lib/logger from MCP-SuperAssistant
 */

const IS_DEV = typeof import.meta !== "undefined" && (import.meta as any).env?.DEV

type LogLevel = "debug" | "info" | "warn" | "error"

export interface Logger {
  debug(...args: any[]): void
  info(...args: any[]): void
  warn(...args: any[]): void
  error(...args: any[]): void
}

export function createLogger(prefix: string): Logger {
  const fmt = (level: LogLevel) => `[${prefix}][${level.toUpperCase()}]`

  return {
    debug(...args: any[]) {
      if (IS_DEV) console.debug(fmt("debug"), ...args)
    },
    info(...args: any[]) {
      console.info(fmt("info"), ...args)
    },
    warn(...args: any[]) {
      console.warn(fmt("warn"), ...args)
    },
    error(...args: any[]) {
      console.error(fmt("error"), ...args)
    },
  }
}

/** Global log helper */
export function logMessage(...args: any[]): void {
  if (IS_DEV) console.log("[SuperAssistant]", ...args)
}
