nodesync-cli
Version:
A smart CLI tool to auto-detect, install, and manage the right Node.js version for your project.
28 lines (22 loc) • 714 B
JavaScript
import fs from 'fs';
import path from 'path';
const logFilePath = path.join(process.cwd(), 'nodesync.log');
let loggingEnabled = false;
export function initLogger(enable) {
loggingEnabled = enable;
if (enable) {
fs.writeFileSync(logFilePath, `📝 nodesync log started: ${new Date().toLocaleString()}\n\n`);
}
}
export function log(message) {
const formatted = `[${new Date().toISOString()}] ${message}`;
if (loggingEnabled) {
fs.appendFileSync(logFilePath, formatted + '\n');
}
}
export function logError(error) {
const formatted = `[${new Date().toISOString()}] ❌ ERROR: ${error.message || error}`;
if (loggingEnabled) {
fs.appendFileSync(logFilePath, formatted + '\n');
}
}