Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 306x 136x 3x 3x 101x 69x 4x 5x 96x | import { config } from "../config.js";
class Logger {
private isDebugEnabled(): boolean {
return config.debug === true;
}
debug(message: string, data?: unknown): void {
if (this.isDebugEnabled()) {
const formattedData = data ? `\n${JSON.stringify(data, null, 2)}` : "";
console.log(`[NodeLLM Debug] ${message}${formattedData}`);
}
}
/**
* Log HTTP request details for debugging
*/
logRequest(provider: string, method: string, url: string, body?: unknown): void {
Iif (this.isDebugEnabled()) {
console.log(`[NodeLLM] [${provider}] Request: ${method} ${url}`);
if (body) {
console.log(JSON.stringify(body, null, 2));
}
}
}
/**
* Log HTTP response details for debugging
*/
logResponse(provider: string, status: number, statusText: string, body?: unknown): void {
Iif (this.isDebugEnabled()) {
console.log(`[NodeLLM] [${provider}] Response: ${status} ${statusText}`);
if (body) {
console.log(JSON.stringify(body, null, 2));
}
}
}
warn(message: string): void {
console.warn(`[NodeLLM] ${message}`);
}
error(message: string, error?: Error): void {
console.error(`[NodeLLM Error] ${message}`, error || "");
}
info(message: string): void {
console.log(`[NodeLLM] ${message}`);
}
}
export const logger = new Logger();
|