Be able to set log level from env variable LOG_LEVEL
This commit is contained in:
parent
b60116410a
commit
b7b3392bdd
@ -5,11 +5,12 @@ const pino = require('pino');
|
||||
module.exports = class Logger {
|
||||
constructor () {
|
||||
const { LOG_LEVEL, NODE_ENV } = process.env;
|
||||
const logLevelFromNodeEnv = NODE_ENV === 'test' ? 'fatal' : 'info';
|
||||
const options = {
|
||||
base: null, // Do not bind hostname, pid and friends by default
|
||||
level: LOG_LEVEL || NODE_ENV === 'test' ? 'fatal' : 'info'
|
||||
level: LOG_LEVEL || logLevelFromNodeEnv
|
||||
};
|
||||
const dest = pino.destination({ sync: false });
|
||||
const dest = pino.destination({ sync: false }); // stdout
|
||||
|
||||
this._logger = pino(options, dest);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user