@mimik/sumologic-winston-logger 2.1.12 → 2.1.14
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/.claude/settings.local.json +3 -1
- package/configuration/config.js +12 -13
- package/lib/common.js +9 -2
- package/lib/formatLib.js +1 -1
- package/lib/stackLib.js +2 -2
- package/package.json +5 -5
- package/test/logger.spec.js +12 -0
package/configuration/config.js
CHANGED
|
@@ -8,12 +8,11 @@ import {
|
|
|
8
8
|
ENV_LOCAL,
|
|
9
9
|
NONE_MODE,
|
|
10
10
|
SUMOLOGIC,
|
|
11
|
+
toInt,
|
|
11
12
|
} from '../lib/common.js';
|
|
12
13
|
import process from 'node:process';
|
|
13
14
|
import { readFileSync } from 'node:fs';
|
|
14
15
|
|
|
15
|
-
const DECIMAL = 10;
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
*
|
|
19
18
|
* Logger configuration.
|
|
@@ -124,8 +123,8 @@ const configuration = {
|
|
|
124
123
|
filter: {
|
|
125
124
|
file: process.env.FILTER_FILE || null,
|
|
126
125
|
},
|
|
127
|
-
flushExitDelay:
|
|
128
|
-
flushExitTimeout:
|
|
126
|
+
flushExitDelay: toInt(process.env.FLUSH_EXIT_DELAY, 2000), // in millisecond
|
|
127
|
+
flushExitTimeout: toInt(process.env.FLUSH_EXIT_TIMEOUT, 5000), // in millisecond
|
|
129
128
|
noStack: process.env.NO_STACK || 'yes',
|
|
130
129
|
};
|
|
131
130
|
configuration.mode = checkMode(process.env.LOG_MODE) || [NONE_MODE];
|
|
@@ -142,13 +141,13 @@ if (configuration.mode.includes(AWS_KINESIS)) {
|
|
|
142
141
|
streamNameError: process.env.KINESIS_AWS_STREAM_NAME_ERROR,
|
|
143
142
|
streamNameOther: process.env.KINESIS_AWS_STREAM_NAME_OTHER,
|
|
144
143
|
region: process.env.KINESIS_AWS_REGION,
|
|
145
|
-
timeout:
|
|
146
|
-
maxSize:
|
|
147
|
-
maxEvents:
|
|
148
|
-
maxRetries:
|
|
144
|
+
timeout: toInt(process.env.KINESIS_AWS_TIMEOUT, 5), // in minute
|
|
145
|
+
maxSize: toInt(process.env.KINESIS_AWS_MAX_SIZE, 5), // in mByte
|
|
146
|
+
maxEvents: toInt(process.env.KINESIS_AWS_MAX_EVENTS, 1000),
|
|
147
|
+
maxRetries: toInt(process.env.KINESIS_AWS_MAX_RETRIES, 4),
|
|
149
148
|
httpOptions: {
|
|
150
|
-
socketTimeout:
|
|
151
|
-
connectionTimeout:
|
|
149
|
+
socketTimeout: toInt(process.env.KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT, 5000), // in millisecond
|
|
150
|
+
connectionTimeout: toInt(process.env.KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT, 5000), // in millisecond
|
|
152
151
|
},
|
|
153
152
|
};
|
|
154
153
|
|
|
@@ -159,9 +158,9 @@ if (configuration.mode.includes(AWS_S3)) {
|
|
|
159
158
|
configuration[AWS_S3] = {
|
|
160
159
|
bucketname: process.env.S3_AWS_BUCKET_NAME,
|
|
161
160
|
region: process.env.S3_AWS_REGION,
|
|
162
|
-
timeout:
|
|
163
|
-
maxSize:
|
|
164
|
-
maxEvents:
|
|
161
|
+
timeout: toInt(process.env.S3_AWS_TIMEOUT, 5), // in minute
|
|
162
|
+
maxSize: toInt(process.env.S3_AWS_MAX_SIZE, 5), // in mByte
|
|
163
|
+
maxEvents: toInt(process.env.S3_AWS_MAX_EVENTS, 1000),
|
|
165
164
|
};
|
|
166
165
|
|
|
167
166
|
if (process.env.S3_AWS_ACCESS_KEY_ID !== undefined) configuration[AWS_S3].accessKeyId = process.env.S3_AWS_ACCESS_KEY_ID;
|
package/lib/common.js
CHANGED
|
@@ -53,6 +53,12 @@ const safeStringify = (obj) => {
|
|
|
53
53
|
});
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
const DECIMAL = 10;
|
|
57
|
+
const toInt = (value, fallback) => {
|
|
58
|
+
const parsed = parseInt(value, DECIMAL);
|
|
59
|
+
return Number.isNaN(parsed) ? fallback : parsed;
|
|
60
|
+
};
|
|
61
|
+
|
|
56
62
|
export {
|
|
57
63
|
ALL_MODE,
|
|
58
64
|
ALL_MODES,
|
|
@@ -65,7 +71,6 @@ export {
|
|
|
65
71
|
ERROR,
|
|
66
72
|
FLUSH,
|
|
67
73
|
FLUSH_EXIT,
|
|
68
|
-
TEST_FLUSH_TIMEOUT,
|
|
69
74
|
INFO,
|
|
70
75
|
LEVEL,
|
|
71
76
|
LOG,
|
|
@@ -79,13 +84,15 @@ export {
|
|
|
79
84
|
OTHER,
|
|
80
85
|
PARTITION_KEY,
|
|
81
86
|
SPLAT,
|
|
82
|
-
TEST_START_TIMEOUT,
|
|
83
87
|
SUMOLOGIC,
|
|
84
88
|
SYSTEM_ERROR,
|
|
85
89
|
TEAPOT_ERROR,
|
|
90
|
+
TEST_FLUSH_TIMEOUT,
|
|
91
|
+
TEST_START_TIMEOUT,
|
|
86
92
|
UNAUTHORIZED_ERROR,
|
|
87
93
|
UNKNOWN_TYPE,
|
|
88
94
|
UNKNOWN_ID,
|
|
89
95
|
WARN,
|
|
90
96
|
safeStringify,
|
|
97
|
+
toInt,
|
|
91
98
|
};
|
package/lib/formatLib.js
CHANGED
package/lib/stackLib.js
CHANGED
|
@@ -45,8 +45,8 @@ const parseStack = (newError) => {
|
|
|
45
45
|
stackInfo.hash = createHash('sha256')
|
|
46
46
|
.update(stackInfo.stack)
|
|
47
47
|
.digest('hex');
|
|
48
|
-
// this is a hash of the
|
|
49
|
-
// security of this is not a concern since
|
|
48
|
+
// this is a hash of the stack trace for easier searching for the stack trace
|
|
49
|
+
// security of this is not a concern since the stack trace is also sent unencrypted
|
|
50
50
|
return stackInfo;
|
|
51
51
|
};
|
|
52
52
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/sumologic-winston-logger",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.14",
|
|
4
4
|
"description": "Log wrapper for sumo, s3, kinesis and winston",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@mimik/lib-filters": "^2.0.7",
|
|
35
|
-
"@aws-sdk/client-s3": "3.
|
|
36
|
-
"@aws-sdk/client-kinesis": "3.
|
|
37
|
-
"@smithy/node-http-handler": "4.4.
|
|
35
|
+
"@aws-sdk/client-s3": "3.998.0",
|
|
36
|
+
"@aws-sdk/client-kinesis": "3.998.0",
|
|
37
|
+
"@smithy/node-http-handler": "4.4.12",
|
|
38
38
|
"axios": "1.13.5",
|
|
39
39
|
"winston": "3.19.0",
|
|
40
40
|
"winston-transport": "4.9.0"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@mimik/request-helper": "^2.0.5",
|
|
46
46
|
"@stylistic/eslint-plugin": "5.9.0",
|
|
47
47
|
"aws-sdk-client-mock": "4.1.0",
|
|
48
|
-
"c8": "
|
|
48
|
+
"c8": "11.0.0",
|
|
49
49
|
"chai": "6.2.2",
|
|
50
50
|
"eslint": "9.39.2",
|
|
51
51
|
"eslint-plugin-import": "2.32.0",
|
package/test/logger.spec.js
CHANGED
|
@@ -183,6 +183,18 @@ describe('Sumologic transport', function SumoTests() {
|
|
|
183
183
|
});
|
|
184
184
|
sumo.log({ level: 'info', message: 'test globalThis' });
|
|
185
185
|
});
|
|
186
|
+
|
|
187
|
+
it('falls back to unknownServerId when globalThis.serverId is not set', (done) => {
|
|
188
|
+
globalThis.serverType = 'mSumoRemote';
|
|
189
|
+
sumo.code = '401';
|
|
190
|
+
sumo.once('warn', (resp) => {
|
|
191
|
+
resp.data.should.have.property('serverType', 'mSumoRemote');
|
|
192
|
+
resp.data.should.have.property('serverId', 'unknownServerId@clients');
|
|
193
|
+
delete globalThis.serverType;
|
|
194
|
+
done();
|
|
195
|
+
});
|
|
196
|
+
sumo.log({ level: 'info', message: 'test serverId fallback' });
|
|
197
|
+
});
|
|
186
198
|
});
|
|
187
199
|
|
|
188
200
|
describe('S3 transport', function S3Tests() {
|