Initial commit with translated description

This commit is contained in:
2026-03-29 08:34:04 +08:00
commit 80ef0a90d7
24 changed files with 4556 additions and 0 deletions

33
utils/logger.js Normal file
View File

@@ -0,0 +1,33 @@
const fs = require('fs');
const path = require('path');
const LOG_FILE = path.join(__dirname, '../../../logs/evolver.log');
function log(level, message, data = {}) {
const timestamp = new Date().toISOString();
const logEntry = {
timestamp,
level,
message,
...data
};
// Ensure logs directory exists
const logDir = path.dirname(LOG_FILE);
if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir, { recursive: true });
}
// Append to log file
fs.appendFileSync(LOG_FILE, JSON.stringify(logEntry) + '\n');
// Also log to console for immediate visibility
console.log(`[${level}] ${message}`, JSON.stringify(data));
}
module.exports = {
info: (msg, data) => log('INFO', msg, data),
error: (msg, data) => log('ERROR', msg, data),
warn: (msg, data) => log('WARN', msg, data),
debug: (msg, data) => log('DEBUG', msg, data)
};