@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.
@@ -2,7 +2,9 @@
2
2
  "permissions": {
3
3
  "allow": [
4
4
  "Bash(npx mocha:*)",
5
- "Bash(done)"
5
+ "Bash(done)",
6
+ "Bash(npm test)",
7
+ "Bash(git status -u)"
6
8
  ]
7
9
  }
8
10
  }
@@ -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: parseInt(process.env.FLUSH_EXIT_DELAY, DECIMAL) || 2000, // in millisecond
128
- flushExitTimeout: parseInt(process.env.FLUSH_EXIT_TIMEOUT, DECIMAL) || 5000, // in millisecond
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: parseInt(process.env.KINESIS_AWS_TIMEOUT, DECIMAL) || 5, // in minute
146
- maxSize: parseInt(process.env.KINESIS_AWS_MAX_SIZE, DECIMAL) || 5, // in mByte
147
- maxEvents: parseInt(process.env.KINESIS_AWS_MAX_EVENTS, DECIMAL) || 1000,
148
- maxRetries: parseInt(process.env.KINESIS_AWS_MAX_RETRIES, DECIMAL) || 4,
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: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT, DECIMAL) || 5000, // in millisecond
151
- connectionTimeout: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT, DECIMAL) || 5000, // in millisecond
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: parseInt(process.env.S3_AWS_TIMEOUT, DECIMAL) || 5, // in minute
163
- maxSize: parseInt(process.env.S3_AWS_MAX_SIZE, DECIMAL) || 5, // in mByte
164
- maxEvents: parseInt(process.env.S3_AWS_MAX_EVENTS, DECIMAL) || 1000,
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
@@ -20,7 +20,7 @@ const isReserved = (value) => {
20
20
 
21
21
  const stackInfo = format((origInfo, opts) => {
22
22
  const { env, noStack } = opts;
23
- const info = origInfo;
23
+ const info = { ...origInfo };
24
24
 
25
25
  if (info.level === 'error') {
26
26
  info.stackInfo = parseStack(new Error());
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 stacktrace for easier searching for the stacktrace
49
- // security of this is not a concern since stacktrace is also sent unencrypted
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.12",
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.995.0",
36
- "@aws-sdk/client-kinesis": "3.995.0",
37
- "@smithy/node-http-handler": "4.4.10",
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": "10.1.3",
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",
@@ -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() {