-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.js
54 lines (46 loc) · 1.42 KB
/
logger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const winston = require('winston');
const winstonRotator = require('winston-daily-rotate-file');
const { combine, timestamp, printf, colorize, align } = winston.format;
var transport = new winston.transports.DailyRotateFile({
frequency: '1y',
filename: './logs/bot.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '5m',
maxFiles: '10'
});
transport.on('rotate', function (oldFilename, newFilename) {
// do something fun
});
var logger = winston.createLogger({
level: process.env.logLevel || 'verbose',
format: combine(
colorize({ all: true }),
timestamp({
format: 'YYYY-MM-DD HH:mm:ss.SSS',
}),
align(),
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
),
transports: [
transport
]
});
module.exports = {
'logger': logger,
commandUsed: function (user,commandName,guild) {
let log = `${user.username} used the command /${commandName} in guild "${guild.name}".`;
/*
//TODO still need to understand if there's a possibility to access all values that are passed/options that a command has
if (interaction.values !== undefined && interaction.values !== null && interaction.values !== []) {
log += " with the options: "
for (let option in interaction.values) {
log += option.name + ": " + option.value + ", "
}
log = log.slice(0,-2); //removes the last comma
}
*/
log += ".";
return log;
}
};