Improve logging

This commit is contained in:
Isaac 2022-09-26 16:39:32 +01:00
parent 00b85cd5dd
commit 9d46abcbb3
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
11 changed files with 83 additions and 7 deletions

View File

@ -127,7 +127,7 @@
"off"
],
"no-console": [
"off"
"warn"
],
"no-prototype-builtins": [
"off"

View File

@ -38,7 +38,7 @@ module.exports = config => {
}
return new Logger({
namespaces: ['commands', 'http', 'listeners', 'settings', 'tickets'],
namespaces: ['autocomplete', 'buttons', 'commands', 'http', 'listeners', 'menus', 'modals', 'settings', 'tickets'],
transports,
});
};

View File

@ -10,7 +10,7 @@ module.exports = class extends Listener {
}
run(autocompleter) {
this.client.log.info(`Loaded "${autocompleter.id}" autocompleter`);
this.client.log.info.autocomplete(`Loaded "${autocompleter.id}" autocompleter`);
return true;
}
};

View File

@ -0,0 +1,19 @@
const { Listener } = require('@eartharoid/dbf');
module.exports = class extends Listener {
constructor(client, options) {
super(client, {
...options,
emitter: client.autocomplete,
event: 'run',
});
}
run({
autocompleter,
interaction,
}) {
this.client.log.verbose.autocomplete(`${interaction.user.tag} used the "${autocompleter.id}" autocompleter`);
return true;
}
};

View File

@ -10,7 +10,7 @@ module.exports = class extends Listener {
}
run(button) {
this.client.log.info(`Loaded "${button.id}" button`);
this.client.log.info.buttons(`Loaded "${button.id}" button`);
return true;
}
};

View File

@ -0,0 +1,19 @@
const { Listener } = require('@eartharoid/dbf');
module.exports = class extends Listener {
constructor(client, options) {
super(client, {
...options,
emitter: client.buttons,
event: 'run',
});
}
run({
button,
interaction,
}) {
this.client.log.info.buttons(`${interaction.user.tag} used the "${button.id}" button`);
return true;
}
};

View File

@ -10,7 +10,7 @@ module.exports = class extends Listener {
}
run(menu) {
this.client.log.info(`Loaded "${menu.id}" menu`);
this.client.log.info.menus(`Loaded "${menu.id}" menu`);
return true;
}
};

View File

@ -0,0 +1,19 @@
const { Listener } = require('@eartharoid/dbf');
module.exports = class extends Listener {
constructor(client, options) {
super(client, {
...options,
emitter: client.menus,
event: 'run',
});
}
run({
menu,
interaction,
}) {
this.client.log.info.menus(`${interaction.user.tag} used the "${menu.id}" menu`);
return true;
}
};

View File

@ -10,7 +10,7 @@ module.exports = class extends Listener {
}
run(modal) {
this.client.log.info(`Loaded "${modal.id}" modal`);
this.client.log.info.modals(`Loaded "${modal.id}" modal`);
return true;
}
};

View File

@ -0,0 +1,19 @@
const { Listener } = require('@eartharoid/dbf');
module.exports = class extends Listener {
constructor(client, options) {
super(client, {
...options,
emitter: client.modals,
event: 'run',
});
}
run({
modal,
interaction,
}) {
this.client.log.info.modals(`${interaction.user.tag} used the "${modal.id}" modal`);
return true;
}
};

View File

@ -10,6 +10,6 @@ module.exports = class extends Listener {
}
run(commandName) {
console.log('Unknown command:', commandName);
this.client.log.warn('Unknown command:', commandName);
}
};