Introduce different log levels

This commit is contained in:
Michael Jackson
2018-08-25 23:49:44 -07:00
parent fe4ccec4e2
commit 82d404a973
4 changed files with 36 additions and 9 deletions

24
modules/utils/logging.js Normal file
View File

@ -0,0 +1,24 @@
const log = console.log.bind(console);
function noop() {}
let debug, info, warn;
if (process.env.LOG_LEVEL === "none") {
debug = info = warn = noop;
} else if (process.env.LOG_LEVEL === "debug") {
debug = info = warn = log;
} else if (process.env.LOG_LEVEL === "warn") {
debug = info = noop;
warn = log;
} else {
// default LOG_LEVEL = "info"
debug = noop;
info = warn = log;
}
module.exports = {
debug,
info,
warn
};