// 自定义 Console 类（与 Vue 实例 logger 对齐：支持按路径配置、前缀；业务逻辑中 log.xx 使用 Expression 序列化）
export interface ILogicLogger {
  log: (...args: any[]) => void
  debug: (...args: any[]) => void
  info: (...args: any[]) => void
  warn: (...args: any[]) => void
  error: (...args: any[]) => void
}

export default class LogicConsole {

  public debug(...args: any[]): void {
    const newArgs = this.convert(args);
    console.debug(...newArgs);
  }

  public info(...args: any[]): void {
    const newArgs = this.convert(args);
    console.info(...newArgs);
  }

  public warn(...args: any[]): void {
    const newArgs = this.convert(args);
    console.warn(...newArgs);
  }

  public error(...args: any[]): void {
    const newArgs = this.convert(args);
    console.error(...newArgs);
  }

  /**
   * 创建带路径的 logger，与 Vue 实例的 logger 行为一致（配置开关、前缀）。
   * 实际实现见 LogicConsole.js；此处仅为类型声明与兜底。
   */
  public static createLogger(logPath: string): ILogicLogger {
    const noop = () => {}
    return { log: noop, debug: noop, info: noop, warn: noop, error: noop }
  }

  private convert(args: any[]): any[] {
    return args.map(arg => {
      if (typeof arg === 'object' && arg !== null && typeof arg.toString === 'function') {
        return arg.toString();
      }
      return arg;
    })
  }
}
