mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
ccaab0c47b
Instead of instructing users to do static calls in to Unleash, she should instead be allwed to specify the log provider as an option to Unleash. This commit introduces the "getLogger" option, a function responsible for creating a logger.
15 lines
369 B
JavaScript
15 lines
369 B
JavaScript
'use strict';
|
|
|
|
const url = require('url');
|
|
|
|
module.exports = function(config) {
|
|
const logger = config.getLogger('HTTP');
|
|
return (req, res, next) => {
|
|
next();
|
|
if (config.enableRequestLogger) {
|
|
const { pathname } = url.parse(req.originalUrl);
|
|
logger.info(`${res.statusCode} ${req.method} ${pathname}`);
|
|
}
|
|
};
|
|
};
|