2018-08-26 06:49:44 +00:00
|
|
|
const log = console.log.bind(console);
|
|
|
|
|
|
|
|
function noop() {}
|
|
|
|
|
|
|
|
let debug, info, warn;
|
|
|
|
|
2018-12-17 17:38:05 +00:00
|
|
|
if (process.env.LOG_LEVEL === 'none') {
|
2018-08-26 06:49:44 +00:00
|
|
|
debug = info = warn = noop;
|
2018-12-17 17:38:05 +00:00
|
|
|
} else if (process.env.LOG_LEVEL === 'debug') {
|
2018-08-26 06:49:44 +00:00
|
|
|
debug = info = warn = log;
|
2018-12-17 17:38:05 +00:00
|
|
|
} else if (process.env.LOG_LEVEL === 'warn') {
|
2018-08-26 06:49:44 +00:00
|
|
|
debug = info = noop;
|
|
|
|
warn = log;
|
|
|
|
} else {
|
|
|
|
// default LOG_LEVEL = "info"
|
|
|
|
debug = noop;
|
|
|
|
info = warn = log;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
debug,
|
|
|
|
info,
|
|
|
|
warn
|
|
|
|
};
|