Commit 57fe0b08464baea480561f4f94c4eea5bfd6cd87
1 parent
b399f8dd7a
Exists in
master
and in
1 other branch
Add more on access log
Showing 1 changed file with 3 additions and 1 deletions Inline Diff
lib/middlewares/common.js
1 | const MODULE_NAME = 'MIDDLEWARES'; | 1 | const MODULE_NAME = 'MIDDLEWARES'; |
2 | 2 | ||
3 | const uuidv1 = require('uuid/v1'); | 3 | const uuidv1 = require('uuid/v1'); |
4 | const uniqid = require('uniqid'); | 4 | const uniqid = require('uniqid'); |
5 | 5 | ||
6 | const config = require('komodo-sdk/config'); | 6 | const config = require('komodo-sdk/config'); |
7 | const logger = require('tektrans-logger'); | 7 | const logger = require('tektrans-logger'); |
8 | 8 | ||
9 | module.exports = function common(req, res, next) { | 9 | module.exports = function common(req, res, next) { |
10 | if (req.url.search('/favicon.ico') === 0) { | 10 | if (req.url.search('/favicon.ico') === 0) { |
11 | res.sendStatus(404); | 11 | res.sendStatus(404); |
12 | return; | 12 | return; |
13 | } | 13 | } |
14 | 14 | ||
15 | res.locals.xid = config.xid_from_uuid ? uuidv1() | 15 | res.locals.xid = config.xid_from_uuid ? uuidv1() |
16 | : uniqid(); | 16 | : uniqid(); |
17 | 17 | ||
18 | res.locals.x_http_request_ts = new Date(); | 18 | res.locals.x_http_request_ts = new Date(); |
19 | 19 | ||
20 | logger.info(`${MODULE_NAME}.COMMON B6257542: Got a request`, { | 20 | logger.info(`${MODULE_NAME}.COMMON B6257542: Got a request`, { |
21 | xid: res.locals.xid, | 21 | xid: res.locals.xid, |
22 | pid: process.pid, | 22 | pid: process.pid, |
23 | subsystem: res.locals.httpgetx_subsystem, | 23 | subsystem: res.locals.httpgetx_subsystem, |
24 | requester_ip: req.ip, | 24 | userAgent: req.get('user-agent'), |
25 | requesterIp: req.ip, | ||
25 | method: req.method, | 26 | method: req.method, |
27 | requestContentType: req.get('content-type'), | ||
26 | path: req.path, | 28 | path: req.path, |
27 | url: req.url, | 29 | url: req.url, |
28 | qs: req.query, | 30 | qs: req.query, |
29 | body: req.body, | 31 | body: req.body, |
30 | }); | 32 | }); |
31 | next(); | 33 | next(); |
32 | }; | 34 | }; |
33 | 35 |