/**
* @copyright 2025 Chris Bunting <cbuntingde@gmail.com>
* @license MIT
*
* Logger utility for the Memory MCP Server
*/
export enum LogLevel {
ERROR = 0,
WARN = 1,
INFO = 2,
DEBUG = 3
}
export class Logger {
private static instance: Logger;
private logLevel: LogLevel = LogLevel.INFO;
private constructor() {}
public static getInstance(): Logger {
if (!Logger.instance) {
Logger.instance = new Logger();
}
return Logger.instance;
}
public setLogLevel(level: LogLevel): void {
this.logLevel = level;
}
public error(message: string, ...args: any[]): void {
if (this.logLevel >= LogLevel.ERROR) {
console.error(`[ERROR] ${message}`, ...args);
}
}
public warn(message: string, ...args: any[]): void {
if (this.logLevel >= LogLevel.WARN) {
console.warn(`[WARN] ${message}`, ...args);
}
}
public info(message: string, ...args: any[]): void {
if (this.logLevel >= LogLevel.INFO) {
console.info(`[INFO] ${message}`, ...args);
}
}
public debug(message: string, ...args: any[]): void {
if (this.logLevel >= LogLevel.DEBUG) {
console.debug(`[DEBUG] ${message}`, ...args);
}
}
}