update logger

This commit is contained in:
Isaac 2022-11-01 21:10:57 +00:00
parent 14df0637ae
commit e105f0c34c
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
2 changed files with 21 additions and 6 deletions

View File

@ -53,7 +53,7 @@
"fs-extra": "^10.1.0", "fs-extra": "^10.1.0",
"keyv": "^4.5.0", "keyv": "^4.5.0",
"leeks.js": "^0.2.4", "leeks.js": "^0.2.4",
"leekslazylogger": "^4.1.7", "leekslazylogger": "^5.0.0",
"ms": "^2.1.3", "ms": "^2.1.3",
"mustache": "^4.2.0", "mustache": "^4.2.0",
"node-dir": "^0.1.17", "node-dir": "^0.1.17",

View File

@ -1,4 +1,8 @@
const Logger = require('leekslazylogger'); const {
ConsoleTransport,
FileTransport,
Logger,
} = require('leekslazylogger');
const DTF = require('@eartharoid/dtf'); const DTF = require('@eartharoid/dtf');
const { short } = require('leeks.js'); const { short } = require('leeks.js');
@ -16,7 +20,7 @@ const colours = {
module.exports = config => { module.exports = config => {
const transports = [ const transports = [
new Logger.transports.ConsoleTransport({ new ConsoleTransport({
format: log => { format: log => {
const timestamp = dtf.fill('DD/MM/YY HH:mm:ss', log.timestamp); const timestamp = dtf.fill('DD/MM/YY HH:mm:ss', log.timestamp);
const colour = colours[log.level.name]; const colour = colours[log.level.name];
@ -28,9 +32,10 @@ module.exports = config => {
if (config.logs.files.enabled) { if (config.logs.files.enabled) {
transports.push( transports.push(
new Logger.transports.FileTransport({ new FileTransport({
clean_directory: config.logs.files.keepFor, clean_directory: config.logs.files.keepFor,
directory: config.logs.files.directory, directory: config.logs.files.directory,
format: '[{timestamp}] [{LEVEL}] ({NAMESPACE}) @{file}:{line}:{column} {content}',
level: config.logs.level, level: config.logs.level,
name: 'Discord Tickets by eartharoid', name: 'Discord Tickets by eartharoid',
}), }),
@ -38,7 +43,17 @@ module.exports = config => {
} }
return new Logger({ return new Logger({
namespaces: ['autocomplete', 'buttons', 'commands', 'http', 'listeners', 'menus', 'modals', 'settings', 'tickets'], namespaces: [
'autocomplete',
'buttons',
'commands',
'http',
'listeners',
'menus',
'modals',
'settings',
'tickets',
],
transports, transports,
}); });
}; };