@chainreactionom/nano-mcp
Version:
NANO cryptocurrency wallet implementation for MCP with comprehensive testing
39 lines (33 loc) • 931 B
JavaScript
import fs from 'fs';
import path from 'path';
export class Logger {
constructor(logDir) {
this.logDir = logDir;
this.ensureLogDirectory();
}
ensureLogDirectory() {
if (!fs.existsSync(this.logDir)) {
fs.mkdirSync(this.logDir, { recursive: true });
}
}
getLogFilePath() {
const date = new Date().toISOString().split('T')[0];
return path.join(this.logDir, `${date}.log`);
}
log(type, data) {
const timestamp = new Date().toISOString();
const logEntry = {
timestamp,
type,
data
};
const logFile = this.getLogFilePath();
fs.appendFileSync(logFile, JSON.stringify(logEntry) + '\n');
}
logError(type, error) {
this.log(type, {
message: error.message,
stack: error.stack
});
}
}