diff --git a/lib/utils/logger.js b/lib/utils/logger.js index 54beee2e..3acc1166 100644 --- a/lib/utils/logger.js +++ b/lib/utils/logger.js @@ -1,12 +1,17 @@ 'use strict'; const pino = require('pino'); -const { req: requestSerializer, res: responseSerializer, err: errorSerializer } = pino.stdSerializers; +const { req: requestSerializer, res: responseSerializer, err, wrapErrorSerializer } = pino.stdSerializers; +const DEV_ENVS = ['test', 'development']; module.exports = class Logger { constructor () { const { LOG_LEVEL, NODE_ENV } = process.env; const logLevelFromNodeEnv = NODE_ENV === 'test' ? 'fatal' : 'info'; + const errorSerializer = DEV_ENVS.includes(NODE_ENV) ? err : wrapErrorSerializer(err => { + err.stack = err.stack.split('\n').slice(0, 3).join('\n'); + return err; + }); const options = { base: null, // Do not bind hostname, pid and friends by default level: LOG_LEVEL || logLevelFromNodeEnv, diff --git a/package-lock.json b/package-lock.json index fe1e59de..580ad405 100644 --- a/package-lock.json +++ b/package-lock.json @@ -796,7 +796,7 @@ "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" }, "camshaft": { - "version": "github:cartodb/camshaft#8d8f62d3d98b4ac316d8444ac3f3f321c28040dc", + "version": "github:cartodb/camshaft#633d3b85869d894d52ac5c9970462f326d2f42cc", "from": "github:cartodb/camshaft#dgaubert/ch78389/camshaft-replace-logger-from-bunyan-to-pino", "requires": { "async": "^1.5.2",