micronodelib 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/logging/logger.js +10 -9
- package/dist/logging/middleware.js +20 -18
- package/package.json +1 -1
package/dist/logging/logger.js
CHANGED
@@ -35,16 +35,17 @@ const util = __importStar(require("util"));
|
|
35
35
|
// and used to log messages.
|
36
36
|
const winstonLogger = winston_1.default.createLogger({
|
37
37
|
format: (0, configuration_1.formatter)(info => {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
request_meta: {
|
44
|
-
request_id: (0, express_http_context_1.get)('reqId'),
|
45
|
-
},
|
46
|
-
stacktrace: info.stack
|
38
|
+
info.level = info.level.toUpperCase();
|
39
|
+
info.msg = info.message;
|
40
|
+
info.ts = Date.parse(info.timestamp) / 1000;
|
41
|
+
info.request_meta = {
|
42
|
+
request_id: (0, express_http_context_1.get)('reqId')
|
47
43
|
};
|
44
|
+
info.stacktrace = info.stack;
|
45
|
+
info.message = null;
|
46
|
+
delete info.timestamp;
|
47
|
+
delete info.stack;
|
48
|
+
return info;
|
48
49
|
}),
|
49
50
|
transports: configuration_1.transports,
|
50
51
|
});
|
@@ -13,25 +13,27 @@ const requestLogMiddleware = function (opt) {
|
|
13
13
|
msg: 'finish router',
|
14
14
|
format: (0, configuration_1.formatter)(info => {
|
15
15
|
const req = info.meta.req;
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
user_agent: req.headers['user-agent']
|
33
|
-
}
|
16
|
+
info.level = info.level.toUpperCase();
|
17
|
+
info.msg = info.message;
|
18
|
+
info.ts = Date.parse(info.timestamp) / 1000;
|
19
|
+
info.request_meta = {
|
20
|
+
status: info.meta.res.statusCode,
|
21
|
+
execution_time: info.meta.responseTime,
|
22
|
+
request_pattern: url_1.default.parse(req.url).pathname,
|
23
|
+
request_path: url_1.default.parse(req.url).pathname,
|
24
|
+
request_method: req.method,
|
25
|
+
query: new URLSearchParams(req.query).toString(),
|
26
|
+
url: req.url,
|
27
|
+
device_id: req.headers['device-id'],
|
28
|
+
device_session_id: req.headers['device-session-id'],
|
29
|
+
request_id: req.headers['x-request-id'],
|
30
|
+
client_ip: req.headers['x-forwarded-for'] || (req.connection ? req.connection.remoteAddress : null),
|
31
|
+
user_agent: req.headers['user-agent']
|
34
32
|
};
|
33
|
+
info.message = null;
|
34
|
+
delete info.timestamp;
|
35
|
+
delete info.meta;
|
36
|
+
return info;
|
35
37
|
}),
|
36
38
|
transports: configuration_1.transports,
|
37
39
|
ignoreRoute: function (req, res) {
|