2022-05-05 23:29:28 +03:00
|
|
|
const Logger = require('leekslazylogger');
|
|
|
|
const DTF = require('@eartharoid/dtf');
|
|
|
|
const { short } = require('leeks.js');
|
2022-03-18 18:27:32 +02:00
|
|
|
|
2022-05-06 13:09:56 +03:00
|
|
|
const dtf = new DTF('en-GB');
|
2022-03-18 18:27:32 +02:00
|
|
|
const colours = {
|
|
|
|
critical: ['&!4&f', '&!4&f'],
|
|
|
|
debug: ['&1', '&9'],
|
|
|
|
error: ['&4', '&c'],
|
|
|
|
info: ['&3', '&b'],
|
|
|
|
notice: ['&!6&0', '&!6&0'],
|
|
|
|
success: ['&2', '&a'],
|
2022-09-07 23:24:16 +03:00
|
|
|
verbose: ['&7', '&f'],
|
2022-03-18 18:27:32 +02:00
|
|
|
warn: ['&6', '&e'],
|
|
|
|
};
|
|
|
|
|
2022-05-05 23:29:28 +03:00
|
|
|
module.exports = config => {
|
2022-03-18 18:27:32 +02:00
|
|
|
const transports = [
|
|
|
|
new Logger.transports.ConsoleTransport({
|
|
|
|
format: log => {
|
|
|
|
const timestamp = dtf.fill('DD/MM/YY HH:mm:ss', log.timestamp);
|
|
|
|
const colour = colours[log.level.name];
|
|
|
|
return short(`&f&!7${timestamp}&r ${colour[0]}[${log.level.name.toUpperCase()}]&r ${log.namespace ? `&d(${log.namespace.toUpperCase()})&r ` : ''}${colour[1]}${log.content}`);
|
|
|
|
},
|
|
|
|
level: config.logs.level,
|
2022-05-05 23:29:28 +03:00
|
|
|
}),
|
2022-03-18 18:27:32 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
if (config.logs.files.enabled) {
|
|
|
|
transports.push(
|
|
|
|
new Logger.transports.FileTransport({
|
|
|
|
clean_directory: config.logs.files.keepFor,
|
|
|
|
directory: config.logs.files.directory,
|
|
|
|
level: config.logs.level,
|
|
|
|
name: 'Discord Tickets by eartharoid',
|
2022-05-05 23:29:28 +03:00
|
|
|
}),
|
2022-03-18 18:27:32 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Logger({
|
2022-07-18 00:33:42 +03:00
|
|
|
namespaces: ['commands', 'http', 'listeners', 'settings', 'tickets'],
|
2022-03-18 18:27:32 +02:00
|
|
|
transports,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|