// scanner/logger.js const fs = require('fs'); const path = require('path'); const LOG_MODE = process.env.LOG_MODE || "console"; // console | file | both const LOG_FILE = process.env.LOG_FILE || "scan.log"; let stream = null; if (LOG_MODE === "file" || LOG_MODE === "both") { const logPath = path.resolve(__dirname, "..", LOG_FILE); stream = fs.createWriteStream(logPath, { flags: "a" }); } function ts() { return new Date().toISOString().replace("T", " ").split(".")[0]; } function log(message) { const line = `${ts()} ${message}\n`; if (LOG_MODE === "console" || LOG_MODE === "both") { process.stdout.write(line); } if (LOG_MODE === "file" || LOG_MODE === "both") { stream.write(line); } } module.exports = { log };