micronodelib 1.0.4 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +13 -1
- package/dist/logging/logger.js +3 -2
- package/dist/logging/middleware.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -38,4 +38,16 @@ app.listen(3000, () => {
|
|
38
38
|
# Using standard log level: debug, info, warn, error
|
39
39
|
Logger.info('App started');
|
40
40
|
})
|
41
|
-
```
|
41
|
+
```
|
42
|
+
|
43
|
+
## Sample output format
|
44
|
+
|
45
|
+
**Standard log format**
|
46
|
+
```json
|
47
|
+
{"level":"INFO","msg":"Test log message","request_meta":{"request_id":"a06dd50a-7127-4f87-bfe0-b7104fb453c9"},"ts":1652842663}
|
48
|
+
```
|
49
|
+
|
50
|
+
**Http request log format**
|
51
|
+
```json
|
52
|
+
{"level":"INFO","msg":"finish router","request_meta":{"client_ip":null,"execution_time":4,"query":"","request_id":"a06dd50a-7127-4f87-bfe0-b7104fb453c9","request_method":"GET","request_path":"/example-path","request_pattern":"/example-path","status":200,"url":"/example-path","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36"},"ts":1652842718}
|
53
|
+
```
|
package/dist/logging/logger.js
CHANGED
@@ -37,12 +37,13 @@ const winstonLogger = winston_1.default.createLogger({
|
|
37
37
|
format: (0, configuration_1.formatter)(info => {
|
38
38
|
info.level = info.level.toUpperCase();
|
39
39
|
info.msg = info.message;
|
40
|
-
info.ts = Date.parse(info.timestamp) / 1000;
|
40
|
+
info.ts = Math.round(Date.parse(info.timestamp) / 1000);
|
41
41
|
info.request_meta = {
|
42
42
|
request_id: (0, express_http_context_1.get)('reqId')
|
43
43
|
};
|
44
44
|
info.stacktrace = info.stack;
|
45
|
-
|
45
|
+
// @ts-ignore
|
46
|
+
delete info.message;
|
46
47
|
delete info.timestamp;
|
47
48
|
delete info.stack;
|
48
49
|
return info;
|
@@ -15,7 +15,7 @@ const requestLogMiddleware = function (opt) {
|
|
15
15
|
const req = info.meta.req;
|
16
16
|
info.level = info.level.toUpperCase();
|
17
17
|
info.msg = info.message;
|
18
|
-
info.ts = Date.parse(info.timestamp) / 1000;
|
18
|
+
info.ts = Math.round(Date.parse(info.timestamp) / 1000);
|
19
19
|
info.request_meta = {
|
20
20
|
status: info.meta.res.statusCode,
|
21
21
|
execution_time: info.meta.responseTime,
|
@@ -30,7 +30,8 @@ const requestLogMiddleware = function (opt) {
|
|
30
30
|
client_ip: req.headers['x-forwarded-for'] || (req.connection ? req.connection.remoteAddress : null),
|
31
31
|
user_agent: req.headers['user-agent']
|
32
32
|
};
|
33
|
-
|
33
|
+
// @ts-ignore
|
34
|
+
delete info.message;
|
34
35
|
delete info.timestamp;
|
35
36
|
delete info.meta;
|
36
37
|
return info;
|