export enum LogLevel { OFF = 0, ERROR = 1, WARN = 2, INFO = 3, DEBUG = 4 } export class Logger { private static logLevel: LogLevel = LogLevel.INFO; // 默认日志级别 static initialize() { const logLevelEnv = process.env.REAI_RAG_LOG_LEVEL; if (logLevelEnv) { this.logLevel = LogLevel[logLevelEnv as keyof typeof LogLevel] || LogLevel.INFO; } } static error(...args: any) { this.initialize() if (this.logLevel >= LogLevel.ERROR) { console.error("[ReAI-RAG]", ...args); } } static warn(...args: any) { this.initialize() if (this.logLevel >= LogLevel.WARN) { console.warn("[ReAI-RAG]", ...args); } } static info(...args: any) { this.initialize() if (this.logLevel >= LogLevel.INFO) { console.log("[ReAI-RAG]", ...args); } } static debug(...args: any) { this.initialize() if (this.logLevel >= LogLevel.DEBUG) { console.debug("[ReAI-RAG]", ...args); } } }