FridayNightFunkinBoyfriendBot/util/logger.js

24 lines
828 B
JavaScript
Raw Permalink Normal View History

2023-12-26 18:45:18 -05:00
const fs = require('fs');
const path = require('path');
const currentDate = new Date();
const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1).toString().padStart(2, '0')}-${currentDate.getDate().toString().padStart(2, '0')}`;
const logFolder = path.join(__dirname, '../logs');
const logFileName = `${timestamp}.txt`;
2023-12-26 18:45:18 -05:00
const logFilePath = path.join(logFolder, logFileName);
const logStream = fs.createWriteStream(logFilePath, { flags: 'a' });
function log (message, bot, toFile = true, toConsole = true ) {
2023-12-26 18:45:18 -05:00
const now = new Date().toLocaleString();
if (bot.options.filelogging = true) {
const toWrite = `${message}`
}
2023-12-26 18:45:18 -05:00
if (toFile) logStream.write(toWrite + '\n');
//if (toConsole) console.log(toWrite);
2023-12-26 18:45:18 -05:00
};
if (!fs.existsSync(logFolder)) {
fs.mkdirSync(logFolder);
}
//ohio
module.exports = log