CartoDB-SQL-API/lib/api/middlewares/logger.js
2020-07-23 12:14:39 +02:00

12 lines
317 B
JavaScript

'use strict';
const uuid = require('uuid');
module.exports = function initLogger ({ logger }) {
return function initLoggerMiddleware (req, res, next) {
const requestId = req.get('X-Request-Id') || uuid.v4();
res.locals.logger = logger.child({ request_id: requestId });
next();
};
};