forked from Galactic/galactic-bot
transporter -> logger
This commit is contained in:
parent
66224698fc
commit
c5d6e0c545
62
structure/client/Logger.js
Normal file
62
structure/client/Logger.js
Normal file
@ -0,0 +1,62 @@
|
||||
const chalk = require('chalk');
|
||||
|
||||
class Logger {
|
||||
|
||||
constructor(client) {
|
||||
|
||||
this.client = client;
|
||||
|
||||
this.client.hooker.hook('ready', () => {
|
||||
this.transport(`Client connected to ${chalk.bold(this.client.user.tag)} with ${chalk.bold(`${this.client.guilds.size} guild${this.client.guilds.size === 1 ? '' : 's'}`)}.`, { embed: true, type: 'SUCCESS' });
|
||||
});
|
||||
|
||||
this.client.hooker.hook('componentUpdate', ({ component, type }) => {
|
||||
this.info(`Component ${chalk.bold(component.resolveable)} was ${chalk.bold(Constants.ComponentTypes[type])}.`);
|
||||
});
|
||||
|
||||
this.client.hooker.hook('reconnect', () => {
|
||||
this.warn(`Shard is reconnecting.`, { embed: true });
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async transport(message = 'N/A', opts = {}) {
|
||||
process.send({ message, ...opts });
|
||||
}
|
||||
|
||||
/* Quick & Dirty Functions */
|
||||
|
||||
log(message, opts = {}) {
|
||||
this.transport(message, { ...opts, type: 'LOG' });
|
||||
}
|
||||
|
||||
info(message, opts = {}) {
|
||||
this.transport(message, { ...opts, type: 'INFO' });
|
||||
}
|
||||
|
||||
warn(message, opts = {}) {
|
||||
this.transport(message, { ...opts, type: 'WARN' });
|
||||
}
|
||||
|
||||
debug(message, opts = {}) {
|
||||
this.transport(message, { ...opts, type: 'DEBUG' });
|
||||
}
|
||||
|
||||
error(message, opts = {}) {
|
||||
this.transport(message, { ...opts, type: 'ERROR' });
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
module.exports = Logger;
|
||||
|
||||
const Constants = {
|
||||
ComponentTypes: {
|
||||
LOAD: 'loaded',
|
||||
UNLOAD: 'unloaded',
|
||||
RELOAD: 'reloaded',
|
||||
ENABLE: 'enabled',
|
||||
DISABLE: 'disabled'
|
||||
}
|
||||
};
|
@ -1,12 +0,0 @@
|
||||
class Transporter {
|
||||
|
||||
constructor(manager) {
|
||||
|
||||
this.manager = manager;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
module.exports = Transporter;
|
Loading…
Reference in New Issue
Block a user