feat(*): Add winston for logging

This commit is contained in:
2020-10-25 23:46:10 +00:00
parent e5f9056c5e
commit d6e197902c
3 changed files with 272 additions and 1 deletions
+25
View File
@@ -1,7 +1,32 @@
const Discord = require('discord.js');
const winston = require('winston');
const config = require('./config.json');
const client = new Discord.Client();
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { service: 'user-service' },
transports: [
//
// - Write all logs with level `error` and below to `error.log`
// - Write all logs with level `info` and below to `combined.log`
//
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' }),
],
});
//
// If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
//
if (process.env.NODE_ENV !== 'production') {
logger.add(new winston.transports.Console({
format: winston.format.simple(),
}));
}
const queueTitle = '===== QUEUE =====';
let playerQueue = [];