Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 61x 61x 150x 150x 150x 754x 754x 61x | import url from 'url';
import { RequestHandler } from 'express';
import { IUnleashConfig } from '../types/option';
const requestLogger: (config: IUnleashConfig) => RequestHandler = (config) => {
const logger = config.getLogger('HTTP');
const enable = config.server.enableRequestLogger;
return (req, res, next) => {
Iif (enable) {
res.on('finish', () => {
const { pathname } = url.parse(req.originalUrl);
logger.info(`${res.statusCode} ${req.method} ${pathname}`);
});
}
next();
};
};
export default requestLogger;
|