Forked from ceveyne/user-docs
Forked from ceveyne/user-docs
src / utils / ragLogger.ts
/**
* Debug logger for the RAG subsystem.
* Disabled by default; enabled through the global plugin configuration.
*/
import fs from "fs";
import path from "path";
import { logTimestamp } from "../core-bundle.mjs";
let ragDebugEnabled = false;
function logsDir(): string {
return path.join(process.cwd(), "logs");
}
function logFile(): string {
return path.join(logsDir(), "user-docs-plugin.log");
}
export function ragLog(tag: string, message: string): void {
if (!isRagDebugEnabled()) return;
const line = `${logTimestamp()} [${tag}] ${message}\n`;
console.log(`[${tag}] ${message}`);
try {
fs.mkdirSync(logsDir(), { recursive: true });
fs.appendFileSync(logFile(), line);
} catch {
// non-fatal
}
}
export function ragDebug(tag: string, message: string): void {
ragLog(tag, message);
}
export function setRagDebugEnabled(enabled: boolean): void {
ragDebugEnabled = enabled;
}
export function isRagDebugEnabled(): boolean {
return ragDebugEnabled;
}
src / utils / ragLogger.ts
/**
* Debug logger for the RAG subsystem.
* Disabled by default; enabled through the global plugin configuration.
*/
import fs from "fs";
import path from "path";
import { logTimestamp } from "../core-bundle.mjs";
let ragDebugEnabled = false;
function logsDir(): string {
return path.join(process.cwd(), "logs");
}
function logFile(): string {
return path.join(logsDir(), "user-docs-plugin.log");
}
export function ragLog(tag: string, message: string): void {
if (!isRagDebugEnabled()) return;
const line = `${logTimestamp()} [${tag}] ${message}\n`;
console.log(`[${tag}] ${message}`);
try {
fs.mkdirSync(logsDir(), { recursive: true });
fs.appendFileSync(logFile(), line);
} catch {
// non-fatal
}
}
export function ragDebug(tag: string, message: string): void {
ragLog(tag, message);
}
export function setRagDebugEnabled(enabled: boolean): void {
ragDebugEnabled = enabled;
}
export function isRagDebugEnabled(): boolean {
return ragDebugEnabled;
}