Windshaft-cartodb/lib/api/middlewares/logger.js
Daniel García Aubert 163c546236 Replace log4js by pino as logger:
- Logs to stdout, disabled while testing
- Change log calls signature when needed
- Use development version of camshaft
- Removes unused log cofiguration
- Bind request id to log req/res
- Log req at the begining of the cycle and res at the end
2020-06-01 19:18:15 +02:00

16 lines
380 B
JavaScript

'use strict';
const uuid = require('uuid');
module.exports = function logger () {
return function loggerMiddleware (req, res, next) {
const id = req.get('X-Request-Id') || uuid.v4();
res.locals.logger = global.logger.child({ id });
res.locals.logger.info(req);
res.on('finish', () => res.locals.logger.info(res));
next();
};
};