UNPKG

legendaryjs

Version:

LegendaryJS – The ultimate backend framework for speed, power, and simplicity.

21 lines (16 loc) 560 B
// logger/smart-logger.js const fs = require('fs'); const path = require('path'); function smartLogger(req, res, next) { const log = `${new Date().toISOString()} ${req.method} ${req.url}`; console.log('🧠 SmartLogger:', log); // Emit log to studio (if WebSocket exists) if (req.io) { req.io.emit('log', log); } // Optional: store to file or further analytics const logFile = path.join(process.cwd(), 'logs/requests.log'); fs.appendFile(logFile, log + '\n', () => {}); next(); } module.exports = { smartLogger };