Skip to content

Commit

Permalink
Upgrade custom logger to allow silly and extend create table timeout (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
halkeye committed Jun 9, 2020
1 parent c37995f commit 02a0cc0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
16 changes: 5 additions & 11 deletions config/customLog.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
const winston = require("winston");

let logLevel = process.env.CSMM_LOGLEVEL;
const logLevel = process.env.CSMM_LOGLEVEL || 'info';

if (!logLevel) {
logLevel = "debug";
}

if (logLevel !== "debug" && logLevel !== "info") {
throw new Error(`Invalid log level given, please select "debug" or "info"`);
}
const infoAndAbove = ['info', 'warn', 'blank', 'crit'];

const transports = [
new winston.transports.File({
Expand All @@ -25,18 +19,18 @@ const transports = [
})
];

if (logLevel === "debug") {
if (!infoAndAbove.includes(logLevel)) {
transports.push(
new winston.transports.Console({
level: "debug",
level: logLevel,
colorize: true,
timestamp: true,
humanReadableUnhandledException: true
})
);
transports.push(
new winston.transports.File({
level: "debug",
level: logLevel,
name: "debuglog",
timestamp: true,
humanReadableUnhandledException: true,
Expand Down
7 changes: 3 additions & 4 deletions config/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
// Load env vars
require('dotenv').config();


customLogger = require('./customLog').customLogger;

module.exports.log = {
level: process.env.CSMM_LOGLEVEL || 'info',

// Pass in our custom logger, and pass all log levels through.
custom: customLogger,
custom: require('./customLog').customLogger,

// Disable captain's log so it doesn't prefix or stringify our meta data.
inspect: false
Expand Down
7 changes: 1 addition & 6 deletions create_tables.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ process.env.DISCORDBOTTOKEN = '';
process.env.NODE_ENV = 'development';

const configOverrides = Object.assign({}, require('./config/env/production.js'), {
hookTimeout: 4000,
log: {
level: 'error',
custom: null,
inspect: true
},
hookTimeout: 60000,
hooks: {
/* This should get shared somewhere */
views: false,
Expand Down

0 comments on commit 02a0cc0

Please sign in to comment.