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')}`;
|
2024-01-26 21:24:08 -05:00
|
|
|
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' });
|
|
|
|
|
2024-01-26 21:24:08 -05:00
|
|
|
function log (message, bot, toFile = true, toConsole = true ) {
|
2023-12-26 18:45:18 -05:00
|
|
|
const now = new Date().toLocaleString();
|
2024-01-26 21:24:08 -05:00
|
|
|
if (bot.options.filelogging = true) {
|
|
|
|
const toWrite = `${message}`
|
|
|
|
}
|
2023-12-26 18:45:18 -05:00
|
|
|
if (toFile) logStream.write(toWrite + '\n');
|
2024-01-26 21:24:08 -05:00
|
|
|
//if (toConsole) console.log(toWrite);
|
2023-12-26 18:45:18 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!fs.existsSync(logFolder)) {
|
|
|
|
fs.mkdirSync(logFolder);
|
|
|
|
}
|
|
|
|
//ohio
|
|
|
|
module.exports = log
|