logger polishing
This commit is contained in:
parent
4da152f7cc
commit
a438ad07e5
@ -11,11 +11,10 @@ class Manager extends EventEmitter {
|
||||
super();
|
||||
|
||||
this.shardManager = new ShardManager('./structure/client/DiscordClient.js', options);
|
||||
this.logger = new Logger(this);
|
||||
this.storageManager = new StorageManager(this, options.storage)
|
||||
.initialize();
|
||||
|
||||
this.logger = new Logger(this);
|
||||
|
||||
this._built = false;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,91 @@
|
||||
debug: [04-13-2020 09:24:35][shard00] : Shard created.
|
||||
info: [04-13-2020 09:24:35][shard00] : Component module:utility was loaded.
|
||||
info: [04-13-2020 09:24:35][shard00] : Component command:ping was loaded.
|
||||
info: [04-13-2020 09:24:35][shard00] : Component observer:commandHandler was loaded.
|
||||
info: [04-13-2020 09:24:35][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
|
||||
debug: [04-14-2020 12:17:25][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:17:25][shard00] : Shard created.
|
||||
info: [04-14-2020 12:17:25][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:17:25][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:17:25][shard00] : Component observer:commandHandler was loaded.
|
||||
debug: [04-14-2020 12:17:25][shard01] : Shard created.
|
||||
info: [04-14-2020 12:17:25][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:20:34][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:20:34][shard00] : Shard created.
|
||||
info: [04-14-2020 12:20:35][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:20:35][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:20:35][shard00] : Component observer:commandHandler was loaded.
|
||||
info: [04-14-2020 12:20:35][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:23:19][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:23:19][shard00] : Shard created.
|
||||
info: [04-14-2020 12:23:20][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:23:20][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:23:20][shard00] : Component observer:commandHandler was loaded.
|
||||
warn: [04-14-2020 12:23:20][shard00] : Attempted to load an invalid class.
|
||||
info: [04-14-2020 12:23:20][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:23:42][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:23:42][shard00] : Shard created.
|
||||
info: [04-14-2020 12:23:42][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:23:42][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:23:43][shard00] : Component observer:commandHandler was loaded.
|
||||
warn: [04-14-2020 12:23:43][shard00] : Attempted to load an invalid class.
|
||||
info: [04-14-2020 12:23:43][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:24:01][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:24:01][shard00] : Shard created.
|
||||
info: [04-14-2020 12:24:02][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:24:02][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:24:02][shard00] : Component observer:commandHandler was loaded.
|
||||
warn: [04-14-2020 12:24:02][shard00] : Attempted to load an invalid class.
|
||||
info: [04-14-2020 12:24:02][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:24:33][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:24:33][shard00] : Shard created.
|
||||
info: [04-14-2020 12:24:34][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:24:34][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:24:34][shard00] : Component observer:commandHandler was loaded.
|
||||
warn: [04-14-2020 12:24:34][shard00] : Attempted to load an invalid class.
|
||||
info: [04-14-2020 12:24:34][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:24:51][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:24:52][shard00] : Shard created.
|
||||
info: [04-14-2020 12:24:52][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:24:52][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:24:52][shard00] : Component observer:commandHandler was loaded.
|
||||
warn: [04-14-2020 12:24:52][shard00] : Attempted to load an invalid class.
|
||||
info: [04-14-2020 12:24:52][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:25:21][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:25:21][shard00] : Shard created.
|
||||
info: [04-14-2020 12:25:22][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:25:22][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:25:22][shard00] : Component observer:commandHandler was loaded.
|
||||
warn: [04-14-2020 12:25:22][shard00] : Attempted to load an invalid class: "What".
|
||||
info: [04-14-2020 12:25:22][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:26:11][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:26:12][shard00] : Shard created.
|
||||
debug: [04-14-2020 12:26:23][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:26:23][shard00] : Shard created.
|
||||
info: [04-14-2020 12:26:24][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:26:24][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:26:24][shard00] : Component observer:commandHandler was loaded.
|
||||
warn: [04-14-2020 12:26:24][shard00] : Attempted to load an invalid class: "What".
|
||||
info: [04-14-2020 12:26:24][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:26:53][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:26:53][shard00] : Shard created.
|
||||
debug: [04-14-2020 12:26:55][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:26:55][shard00] : Shard created.
|
||||
debug: [04-14-2020 12:26:57][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:27:35][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:27:36][shard00] : Shard created.
|
||||
info: [04-14-2020 12:27:36][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:27:36][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:27:37][shard00] : Component observer:commandHandler was loaded.
|
||||
warn: [04-14-2020 12:27:37][shard00] : Attempted to load an invalid class.
|
||||
info: [04-14-2020 12:27:37][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:27:37][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:39:31][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:39:32][shard00] : Shard created.
|
||||
info: [04-14-2020 12:39:32][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:39:32][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:39:32][shard00] : Component observer:commandHandler was loaded.
|
||||
warn: [04-14-2020 12:39:32][shard00] : Attempted to load an invalid class.
|
||||
info: [04-14-2020 12:39:32][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
debug: [04-14-2020 12:39:51][manager] : Initializing storage providers.
|
||||
debug: [04-14-2020 12:39:51][shard00] : Shard created.
|
||||
info: [04-14-2020 12:39:52][shard00] : Component module:utility was loaded.
|
||||
info: [04-14-2020 12:39:52][shard00] : Component command:ping was loaded.
|
||||
info: [04-14-2020 12:39:52][shard00] : Component observer:commandHandler was loaded.
|
||||
info: [04-14-2020 12:39:52][shard00] : Client connected to asfasf#1551 with 1 guild.
|
||||
|
@ -1,4 +1,4 @@
|
||||
const { createLogger, format, transports, config } = require('winston');
|
||||
const { createLogger, format, transports: { Console }, config } = require('winston');
|
||||
const { combine, label, printf } = format;
|
||||
const moment = require('moment');
|
||||
const chalk = require('chalk');
|
||||
@ -29,7 +29,7 @@ class Logger {
|
||||
transports: [
|
||||
new FileExtension({ filename: `logs/what.log`, level: 'debug'}), //Will NOT log "silly" logs, could change in future.
|
||||
new FileExtension({ filename: `logs/error.log` , level: 'error' }),
|
||||
new transports.Console({ level: 'silly' }), //Will log EVERYTHING.
|
||||
new Console({ level: 'silly' }), //Will log EVERYTHING.
|
||||
new DiscordWebhook({ level: 'error' }) //Broadcast errors to a discord webhook.
|
||||
]
|
||||
});
|
||||
@ -37,7 +37,7 @@ class Logger {
|
||||
//TODO: Add proper date-oriented filenames and add a daily rotation file (?).
|
||||
|
||||
this.shardManager
|
||||
.on('shardCreate', (shard) => this.write(shard, "Shard created.", 'debug'))
|
||||
.on('shardCreate', (shard) => this.write('debug', "Shard created.", shard))
|
||||
.on('message', (shard, message) => this._handleMessage(shard, message));
|
||||
|
||||
}
|
||||
@ -53,11 +53,11 @@ class Logger {
|
||||
|| message._storage
|
||||
|| message._webhook) return undefined; //Properties used for discord.js internal sharding & our own structures. must filter for.
|
||||
|
||||
await this.write(shard, message.message, message.type);
|
||||
this.write(message.type, message.message, shard);
|
||||
|
||||
}
|
||||
|
||||
async write(shard, string = '', type = 'silly') {
|
||||
write(type = 'silly', string = '', shard = null) {
|
||||
|
||||
const color = Constants.Colors[type];
|
||||
const header = `${chalk[color](`[${this.date}][${shard ? `shard${this._shardId(shard)}` : 'manager'}]`)}`;
|
||||
|
@ -6,15 +6,17 @@ class StorageManager {
|
||||
|
||||
constructor(manager, options = {}) {
|
||||
|
||||
this.providers = new Collection();
|
||||
this.manager = manager;
|
||||
|
||||
this.providers = new Collection();
|
||||
this.options = options;
|
||||
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
|
||||
console.log('Initiating storage providers');
|
||||
this.manager.logger.write('debug', "Initializing storage providers.");
|
||||
|
||||
let _providers = path.join(process.cwd(), 'storage', 'providers');
|
||||
let providers = fs.readdirSync(_providers);
|
||||
|
||||
|
@ -23,13 +23,13 @@ class Registry {
|
||||
for(const path of files) {
|
||||
const func = require(path);
|
||||
if(typeof func !== 'function') {
|
||||
//this.client.logger.error("Attempted to index an invalid function as a component.");
|
||||
this.client.logger.warn("Attempted to index an invalid function as a component.");
|
||||
continue;
|
||||
}
|
||||
|
||||
const component = new func(this.client); //Instantiates the component class.
|
||||
if(classToHandle && !(component instanceof classToHandle)) {
|
||||
//this.client.logger.error("Attempted to load an invalid class.");
|
||||
this.client.logger.warn("Attempted to load an invalid class.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -44,12 +44,12 @@ class Registry {
|
||||
async loadComponent(component, directory) {
|
||||
|
||||
if(!(component instanceof Component)) {
|
||||
//this.client.logger.error("Attempted to load an invalid component.");
|
||||
this.client.logger.warn("Attempted to load an invalid component.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if(this.components.has(component.resolveable)) {
|
||||
//this.client.logger.error("Attempted to reload an existing component.");
|
||||
this.client.logger.warn("Attempted to reload an existing component.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -95,8 +95,6 @@ class CommandHandler extends Observer {
|
||||
|
||||
const parsedArguments = await this._parseArguments(message, args);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
async _handleInhibitors(message) {
|
||||
|
Loading…
Reference in New Issue
Block a user