Shortcuts for serializers
This commit is contained in:
parent
1e89821d97
commit
219d2c9044
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const pino = require('pino');
|
||||
const { req: requestSerializer, res: responseSerializer, err: errorSerializer } = pino.stdSerializers;
|
||||
|
||||
module.exports = class Logger {
|
||||
constructor () {
|
||||
@ -10,9 +11,9 @@ module.exports = class Logger {
|
||||
base: null, // Do not bind hostname, pid and friends by default
|
||||
level: LOG_LEVEL || logLevelFromNodeEnv,
|
||||
serializers: {
|
||||
request: pino.stdSerializers.req,
|
||||
response: pino.stdSerializers.res,
|
||||
errors: (errors) => errors.map((err) => pino.stdSerializers.err(err))
|
||||
request: requestSerializer,
|
||||
response: responseSerializer,
|
||||
errors: (errors) => errors.map((err) => errorSerializer(err))
|
||||
}
|
||||
};
|
||||
const dest = pino.destination({ sync: false }); // stdout
|
||||
|
Loading…
Reference in New Issue
Block a user