memory-engineering-mcp
Version:
🧠AI Memory System powered by MongoDB Atlas & Voyage AI - Autonomous memory management with zero manual work
40 lines • 1.42 kB
JavaScript
import { appendFileSync, existsSync, mkdirSync } from 'fs';
import { join } from 'path';
// Logger that writes to file instead of console (console.log breaks MCP protocol)
class FileLogger {
logFile;
constructor() {
// Use environment variable for log directory, fallback to ./logs
const logDir = process.env.LOG_DIRECTORY || join(process.cwd(), 'logs');
if (!existsSync(logDir)) {
mkdirSync(logDir, { recursive: true });
}
this.logFile = join(logDir, `memory-engineering-${new Date().toISOString().split('T')[0]}.log`);
}
log(level, message, ...args) {
const timestamp = new Date().toISOString();
const logEntry = `[${timestamp}] [${level}] ${message} ${args.length > 0 ? JSON.stringify(args) : ''}\n`;
try {
appendFileSync(this.logFile, logEntry);
}
catch (error) {
// Silently fail if we can't write logs
}
}
info(message, ...args) {
this.log('INFO', message, ...args);
}
error(message, ...args) {
this.log('ERROR', message, ...args);
}
warn(message, ...args) {
this.log('WARN', message, ...args);
}
debug(message, ...args) {
if (process.env.NODE_ENV === 'development') {
this.log('DEBUG', message, ...args);
}
}
}
export const logger = new FileLogger();
//# sourceMappingURL=logger.js.map