@mimik/sumologic-winston-logger 1.6.21 → 1.6.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/configuration/config.js +13 -2
- package/lib/awsKinesisTransport.js +8 -0
- package/lib/common.js +6 -0
- package/package.json +22 -21
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@ The following environment variables are needed to configure logger:
|
|
|
6
6
|
| Env variable name | Description | Default | Comments |
|
|
7
7
|
| ----------------- | ----------- | ------- | -------- |
|
|
8
8
|
| SERVER_TYPE | type of the server that is logged | null
|
|
9
|
-
| SERVER_ID |id of the
|
|
9
|
+
| SERVER_ID |id of the server that is logged | null
|
|
10
10
|
| NODE_ENV | environment of the running instance | local | DEFAULT_ENV
|
|
11
11
|
| LOG_LEVEL | log level of the running instance | debug | DEFAULT_LEVEL
|
|
12
12
|
| CONSOLE_LEVEL | log level for the console of the running instance | debug | DEFAULT_LEVEL
|
|
13
13
|
| FILTER_FILE | filename containing filter rules | null | DEFAULT_FILTER_FILE
|
|
14
14
|
| EXIT_DELAY | delay when existing gracefully | 2000 | DEFAULT_EXIT_DELAY in ms
|
|
15
|
-
| NO_STACK |
|
|
15
|
+
| NO_STACK | indicator to log th stack on all log message | no | DEFAULT_NO_STACK
|
|
16
16
|
| LOG_MODE | string with comma separated words defining the logmode for the running instance | sumologic | DEFAULT_SUMOLOGIC (enum: awsS3, awsKinesis, sumologic, all, none)
|
|
17
17
|
|
|
18
18
|
If `LOG_MODE` includes `sumologic` the following environment variables are needed:
|
|
@@ -33,8 +33,11 @@ If `LOG_MODE` includes `awsKinesis` the following environment variables are need
|
|
|
33
33
|
| KINESIS_AWS_TIMEOUT | maximum time before flushing | 1000 | DEFAULT_KINESIS_TIMEOUT in ms
|
|
34
34
|
| KINESIS_AWS_MAX_SIZE | maximum size of the accumulated logs before flushing | 5 | DEFAULT_KINESIS_MAX_SIZE in mB
|
|
35
35
|
| KINESIS_AWS_MAX_EVENTS | maximum number of accumulated logs before flushing | 1000 | DEFAULT_KINESIS_MAX_EVENTS
|
|
36
|
+
| KINESIS_AWS_MAX_RETRIES | Maximum connection retries | 4 | |
|
|
36
37
|
| KINESIS_AWS_ACCESS_KEY_ID | access key id of the stream
|
|
37
38
|
| KINESIS_AWS_SECRET_ACCESS_KEY | access key secret of the stream
|
|
39
|
+
| KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT | HTTP handler socket timeout | 5000 | in millisecond |
|
|
40
|
+
| KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT | HTTP handler connection timeout | 5000 | in millisecond |
|
|
38
41
|
|
|
39
42
|
If `LOG_MODE` includes `awsS3` the following environment variables are needed:
|
|
40
43
|
|
package/configuration/config.js
CHANGED
|
@@ -17,13 +17,13 @@ const difference = require('lodash.difference');
|
|
|
17
17
|
* | Env variable name | Description | Default | Comments |
|
|
18
18
|
* | ----------------- | ----------- | ------- | -------- |
|
|
19
19
|
* | SERVER_TYPE | type of the server that is logged | null
|
|
20
|
-
* | SERVER_ID |id of the
|
|
20
|
+
* | SERVER_ID |id of the server that is logged | null
|
|
21
21
|
* | NODE_ENV | environment of the running instance | local | DEFAULT_ENV
|
|
22
22
|
* | LOG_LEVEL | log level of the running instance | debug | DEFAULT_LEVEL
|
|
23
23
|
* | CONSOLE_LEVEL | log level for the console of the running instance | debug | DEFAULT_LEVEL
|
|
24
24
|
* | FILTER_FILE | filename containing filter rules | null | DEFAULT_FILTER_FILE
|
|
25
25
|
* | EXIT_DELAY | delay when existing gracefully | 2000 | DEFAULT_EXIT_DELAY in ms
|
|
26
|
-
* | NO_STACK |
|
|
26
|
+
* | NO_STACK | indicator to log th stack on all log message | no | DEFAULT_NO_STACK
|
|
27
27
|
* | LOG_MODE | string with comma separated words defining the logmode for the running instance | sumologic | DEFAULT_SUMOLOGIC (enum: awsS3, awsKinesis, sumologic, all, none)
|
|
28
28
|
*
|
|
29
29
|
* If `LOG_MODE` includes `sumologic` the following environment variables are needed:
|
|
@@ -44,8 +44,11 @@ const difference = require('lodash.difference');
|
|
|
44
44
|
* | KINESIS_AWS_TIMEOUT | maximum time before flushing | 1000 | DEFAULT_KINESIS_TIMEOUT in ms
|
|
45
45
|
* | KINESIS_AWS_MAX_SIZE | maximum size of the accumulated logs before flushing | 5 | DEFAULT_KINESIS_MAX_SIZE in mB
|
|
46
46
|
* | KINESIS_AWS_MAX_EVENTS | maximum number of accumulated logs before flushing | 1000 | DEFAULT_KINESIS_MAX_EVENTS
|
|
47
|
+
* | KINESIS_AWS_MAX_RETRIES | Maximum connection retries | 4 | |
|
|
47
48
|
* | KINESIS_AWS_ACCESS_KEY_ID | access key id of the stream
|
|
48
49
|
* | KINESIS_AWS_SECRET_ACCESS_KEY | access key secret of the stream
|
|
50
|
+
* | KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT | HTTP handler socket timeout | 5000 | in millisecond |
|
|
51
|
+
* | KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT | HTTP handler connection timeout | 5000 | in millisecond |
|
|
49
52
|
*
|
|
50
53
|
* If `LOG_MODE` includes `awsS3` the following environment variables are needed:
|
|
51
54
|
*
|
|
@@ -76,6 +79,9 @@ const {
|
|
|
76
79
|
DEFAULT_KINESIS_MAX_SIZE,
|
|
77
80
|
DEFAULT_KINESIS_MAX_EVENTS,
|
|
78
81
|
DEFAULT_KINESIS_TIMEOUT,
|
|
82
|
+
DEFAULT_KINESIS_MAX_RETRIES,
|
|
83
|
+
DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
|
|
84
|
+
DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT,
|
|
79
85
|
DEFAULT_MODE,
|
|
80
86
|
DEFAULT_EXIT_DELAY,
|
|
81
87
|
DEFAULT_NO_STACK,
|
|
@@ -151,6 +157,11 @@ if (configuration.mode.includes(AWS_KINESIS)) {
|
|
|
151
157
|
timeout: parseInt(process.env.KINESIS_AWS_TIMEOUT, 10) || DEFAULT_KINESIS_TIMEOUT, // in ms
|
|
152
158
|
maxSize: parseInt(process.env.KINESIS_AWS_MAX_SIZE, 10) || DEFAULT_KINESIS_MAX_SIZE, // in mB
|
|
153
159
|
maxEvents: parseInt(process.env.KINESIS_AWS_MAX_EVENTS, 10) || DEFAULT_KINESIS_MAX_EVENTS,
|
|
160
|
+
maxRetries: parseInt(process.env.KINESIS_AWS_MAX_RETRIES, 10) || DEFAULT_KINESIS_MAX_RETRIES,
|
|
161
|
+
httpOptions: {
|
|
162
|
+
socketTimeout: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT, 10) || DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
|
|
163
|
+
connectionTimeout: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT, 10) || DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT,
|
|
164
|
+
},
|
|
154
165
|
};
|
|
155
166
|
|
|
156
167
|
if (!isNil(process.env.KINESIS_AWS_ACCESS_KEY_ID)) configuration[AWS_KINESIS].accessKeyId = process.env.KINESIS_AWS_ACCESS_KEY_ID;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const Transport = require('winston-transport');
|
|
2
2
|
const Promise = require('bluebird');
|
|
3
3
|
const { KinesisClient, PutRecordsCommand } = require('@aws-sdk/client-kinesis');
|
|
4
|
+
const { NodeHttpHandler } = require('@smithy/node-http-handler');
|
|
4
5
|
|
|
5
6
|
const {
|
|
6
7
|
AWS_KINESIS,
|
|
@@ -45,6 +46,13 @@ module.exports = class AwsKinesis extends Transport {
|
|
|
45
46
|
secretAccessKey: options.secretAccessKey,
|
|
46
47
|
};
|
|
47
48
|
}
|
|
49
|
+
this.kinesisClientConfig.maxAttempts = options.maxRetries + 1;
|
|
50
|
+
this.kinesisClientConfig.requestHandler = new NodeHttpHandler(
|
|
51
|
+
{
|
|
52
|
+
connectionTimeout: options.httpOptions.connectionTimeout,
|
|
53
|
+
socketTimeout: options.httpOptions.socketTimeout,
|
|
54
|
+
},
|
|
55
|
+
);
|
|
48
56
|
this.kinesis = new KinesisClient(this.kinesisClientConfig);
|
|
49
57
|
|
|
50
58
|
this.time = setInterval(() => {
|
package/lib/common.js
CHANGED
|
@@ -19,6 +19,9 @@ const DEFAULT_S3_TIMEOUT = 5; // max time before sending events to S3, in minute
|
|
|
19
19
|
const DEFAULT_KINESIS_MAX_SIZE = 5; // max size of the data before sending to Kinesis, in mB
|
|
20
20
|
const DEFAULT_KINESIS_MAX_EVENTS = 1000; // max number of events before sending to Kinesis
|
|
21
21
|
const DEFAULT_KINESIS_TIMEOUT = 1000; // max time before sending events to Kinesis, in ms
|
|
22
|
+
const DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT = 5000; // connection timeout for the http handler, in millisecond
|
|
23
|
+
const DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT = 5000; // socket timeout for the http handler, in millisecond
|
|
24
|
+
const DEFAULT_KINESIS_MAX_RETRIES = 4; // max retries to connect to Kinesis
|
|
22
25
|
|
|
23
26
|
const DEFAULT_EXIT_DELAY = 2000; // delay for flushing the transports and exiting, in ms
|
|
24
27
|
const DEFAULT_NO_STACK = 'yes';
|
|
@@ -60,6 +63,9 @@ module.exports = {
|
|
|
60
63
|
DEFAULT_KINESIS_MAX_SIZE,
|
|
61
64
|
DEFAULT_KINESIS_MAX_EVENTS,
|
|
62
65
|
DEFAULT_KINESIS_TIMEOUT,
|
|
66
|
+
DEFAULT_KINESIS_MAX_RETRIES,
|
|
67
|
+
DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
|
|
68
|
+
DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT,
|
|
63
69
|
DEFAULT_EXIT_DELAY,
|
|
64
70
|
DEFAULT_NO_STACK,
|
|
65
71
|
SPLAT,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/sumologic-winston-logger",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.23",
|
|
4
4
|
"description": "Log wrapper for sumo, s3, kinesis and winston",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,10 +32,11 @@
|
|
|
32
32
|
"url": "https://bitbucket.org/mimiktech/sumologic-winston-logger"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@aws-sdk/client-kinesis": "3.665.0",
|
|
36
|
+
"@aws-sdk/client-s3": "3.665.0",
|
|
35
37
|
"@mimik/lib-filters": "^1.5.4",
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
"axios": "1.6.8",
|
|
38
|
+
"@smithy/node-http-handler": "4.3.0",
|
|
39
|
+
"axios": "1.7.7",
|
|
39
40
|
"bluebird": "3.7.2",
|
|
40
41
|
"lodash.difference": "4.5.0",
|
|
41
42
|
"lodash.foreach": "4.5.0",
|
|
@@ -47,29 +48,29 @@
|
|
|
47
48
|
"lodash.split": "4.4.2",
|
|
48
49
|
"lodash.trim": "4.5.1",
|
|
49
50
|
"lodash.trimstart": "4.5.1",
|
|
50
|
-
"winston": "3.
|
|
51
|
-
"winston-transport": "4.
|
|
51
|
+
"winston": "3.14.2",
|
|
52
|
+
"winston-transport": "4.8.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@mimik/eslint-plugin-dependencies": "^2.4.6",
|
|
55
56
|
"@mimik/eslint-plugin-document-env": "^1.0.6",
|
|
56
|
-
"@mimik/request-helper": "^1.7.
|
|
57
|
-
"body-parser": "1.20.
|
|
58
|
-
"chai": "4.
|
|
59
|
-
"eslint": "8.57.
|
|
57
|
+
"@mimik/request-helper": "^1.7.11",
|
|
58
|
+
"body-parser": "1.20.3",
|
|
59
|
+
"chai": "4.5.0",
|
|
60
|
+
"eslint": "8.57.1",
|
|
60
61
|
"eslint-config-airbnb": "19.0.4",
|
|
61
|
-
"eslint-plugin-import": "2.
|
|
62
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
63
|
-
"eslint-plugin-react": "7.
|
|
64
|
-
"eslint-plugin-react-hooks": "4.6.
|
|
65
|
-
"express": "4.
|
|
66
|
-
"husky": "9.
|
|
67
|
-
"jsdoc-to-markdown": "
|
|
62
|
+
"eslint-plugin-import": "2.31.0",
|
|
63
|
+
"eslint-plugin-jsx-a11y": "6.10.0",
|
|
64
|
+
"eslint-plugin-react": "7.37.1",
|
|
65
|
+
"eslint-plugin-react-hooks": "4.6.2",
|
|
66
|
+
"express": "4.21.0",
|
|
67
|
+
"husky": "9.1.6",
|
|
68
|
+
"jsdoc-to-markdown": "9.0.2",
|
|
68
69
|
"lodash": "4.17.21",
|
|
69
|
-
"mocha": "10.3
|
|
70
|
+
"mocha": "10.7.3",
|
|
70
71
|
"mochawesome": "7.1.3",
|
|
71
|
-
"nyc": "
|
|
72
|
-
"sinon": "
|
|
73
|
-
"supertest": "
|
|
72
|
+
"nyc": "17.1.0",
|
|
73
|
+
"sinon": "19.0.2",
|
|
74
|
+
"supertest": "7.0.0"
|
|
74
75
|
}
|
|
75
76
|
}
|