Introduce different log levels
This commit is contained in:
24
modules/utils/logging.js
Normal file
24
modules/utils/logging.js
Normal 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
|
||||
};
|
Reference in New Issue
Block a user