1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/middleware/request-logger.js
2020-04-30 23:04:06 +02:00

17 lines
430 B
JavaScript

'use strict';
const url = require('url');
module.exports = function(config) {
const logger = config.getLogger('HTTP');
return (req, res, next) => {
if (config.enableRequestLogger) {
res.on('finish', () => {
const { pathname } = url.parse(req.originalUrl);
logger.info(`${res.statusCode} ${req.method} ${pathname}`);
});
}
next();
};
};