@mimik/sumologic-winston-logger 2.1.4 → 2.1.6

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 CHANGED
@@ -1,64 +1,66 @@
1
1
  <a name="config"></a>
2
2
 
3
3
  ## config() ⇒ <code>object</code>
4
- The following environment variables are needed to configure logger:
4
+ The following environment variables are used to configure the logger:
5
5
 
6
6
  | Env variable name | Description | Default | Comments |
7
7
  | ----------------- | ----------- | ------- | -------- |
8
- | SERVER_TYPE | Type of the server that is logged | null |
9
- | SERVER_ID | Id of the server that is logged | null |
10
- | NODE_ENV | Environment of the running instance | local |
11
- | LOG_LEVEL | Log level of the running instance | debug |
12
- | CONSOLE_LEVEL | Log level for the console of the running instance | debug |
13
- | FILTER_FILE | Filename containing filter rules | null |
14
- | EXIT_DELAY | Delay when exiting gracefully | 2000 | in millisecond
15
- | NO_STACK | Indicator to log the call stack on all log messages | no |
16
- | LOG_MODE | String with comma separated words defining the log mode for the running instance | sumologic | (enum: awsS3, awsKinesis, sumologic, all, none)
17
-
18
- If `LOG_MODE` includes `sumologic` the following environment variables are needed:
8
+ | SERVER_TYPE | Type of the server being logged | null | |
9
+ | SERVER_ID | ID of the server being logged | null | |
10
+ | NODE_ENV | Environment of the running instance | local | |
11
+ | LOG_LEVEL | Log level for the running instance | debug | |
12
+ | CONSOLE_LEVEL | Console log level | debug | |
13
+ | FILTER_FILE | Filename containing filter rules | null | |
14
+ | EXIT_DELAY | Delay before exiting gracefully | 2000 | in milliseconds |
15
+ | NO_STACK | Whether to include call stacks in all log messages | no | expected: yes/no |
16
+ | LOG_MODE | Comma-separated list defining the log mode/backends | sumologic | enum: awsS3, awsKinesis, sumologic, all, none |
17
+
18
+ If `LOG_MODE` includes `sumologic`, the following environment variables are required:
19
19
 
20
20
  | Env variable name | Description | Default | Comments |
21
21
  | ----------------- | ----------- | ------- | -------- |
22
- | SUMO_LOGIC_ENDPOINT | URL of the sumologic collector
23
- | SUMO_LOGIC_COLLECTOR_CODE | Code of the sumologic collector
22
+ | SUMO_LOGIC_ENDPOINT | URL of the Sumo Logic collector | | |
23
+ | SUMO_LOGIC_COLLECTOR_CODE | Code of the Sumo Logic collector | | |
24
24
 
25
- If `LOG_MODE` includes `awsKinesis` the following environment variables are needed:
25
+ If `LOG_MODE` includes `awsKinesis`, the following environment variables are required:
26
26
 
27
27
  | Env variable name | Description | Default | Comments |
28
28
  | ----------------- | ----------- | ------- | -------- |
29
- | KINESIS_AWS_STREAM_NAME_INFO | Name of the stream for info level logs
30
- | KINESIS_AWS_STREAM_NAME_ERROR | Name of the stream for error level logs
31
- | KINESIS_AWS_STREAM_NAME_OTHER | Name of the stream for any other level logs
32
- | KINESIS_AWS_REGION | Region of the stream
33
- | KINESIS_AWS_TIMEOUT | Maximum time before flushing | 1000 | in millisecond
34
- | KINESIS_AWS_MAX_SIZE | Maximum size of the accumulated logs before flushing | 5 | in mByte
35
- | KINESIS_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000 |
36
- | KINESIS_AWS_ACCESS_KEY_ID | Access key id of the stream
37
- | KINESIS_AWS_SECRET_ACCESS_KEY | Access key secret of the stream
38
- | KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT | Socket timeout for the http handler | 5000 | in millisecond
39
- | KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT | Connection timeout for the http handler | 5000 | in millisecond
40
-
41
- If `LOG_MODE` includes `awsS3` the following environment variables are needed:
29
+ | KINESIS_AWS_STREAM_NAME_INFO | Stream name for `info` level logs | | |
30
+ | KINESIS_AWS_STREAM_NAME_ERROR | Stream name for `error` level logs | | |
31
+ | KINESIS_AWS_STREAM_NAME_OTHER | Stream name for any other level | | |
32
+ | KINESIS_AWS_REGION | AWS region of the stream | | |
33
+ | KINESIS_AWS_TIMEOUT | Maximum time before flushing | 1000 | in millisecond |
34
+ | KINESIS_AWS_MAX_SIZE | Maximum accumulated log size before flushing | 5 | in MB |
35
+ | KINESIS_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000 | |
36
+ | KINESIS_AWS_MAX_RETRIES | Maximum connection retries | 4 | |
37
+ | KINESIS_AWS_ACCESS_KEY_ID | AWS access key ID | | |
38
+ | KINESIS_AWS_SECRET_ACCESS_KEY | AWS secret access key | | |
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 |
41
+
42
+ If `LOG_MODE` includes `awsS3`, the following environment variables are required:
42
43
 
43
44
  | Env variable name | Description | Default | Comments |
44
45
  | ----------------- | ----------- | ------- | -------- |
45
- | S3_AWS_BUCKET_NAME | Name of the bucket for storing the logs
46
- | S3_AWS_REGION | Region of the bucket
47
- | S3_AWS_TIMEOUT | Maximum time before flushing | 5 | in minute
48
- | S3_AWS_MAX_SIZE | Maximum size of the accumulated logs before flushing | 5 | in mByte
49
- | S3_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000 |
50
- | S3_AWS_ACCESS_KEY_ID | Access key id of the bucket
51
- | S3_AWS_SECRET_ACCESS_KEY | Access key secret of the bucket
52
-
53
- When `LOG_MODE` is `none` the logs will only be on `console`.
54
- When `LOG_MODE` is `all` LOG_MODE will be set to `sumologic, awsS3`.
55
-
56
- The SERVER_TYPE and SERVER_ID are used to create the S3 filename and are inserted in the payload of the log for S3 and Kinesis.
57
- If `global.serverType` is set, this value is used over SERVER_TYPE.
58
- If `global.serverType` is set, the value of `global.serverId` is used over `SERVER_ID`.
46
+ | S3_AWS_BUCKET_NAME | S3 bucket name for storing logs | | |
47
+ | S3_AWS_REGION | AWS region of the bucket | | |
48
+ | S3_AWS_TIMEOUT | Maximum time before flushing | 5 | in minute |
49
+ | S3_AWS_MAX_SIZE | Maximum accumulated log size before flushing | 5 | in MB |
50
+ | S3_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000 | |
51
+ | S3_AWS_ACCESS_KEY_ID | AWS access key ID | | |
52
+ | S3_AWS_SECRET_ACCESS_KEY | AWS secret access key | | |
53
+
54
+ When `LOG_MODE` is `none`, logs are written to the console only.
55
+ When `LOG_MODE` is `all`, it is equivalent to `sumologic,awsS3`.
56
+
57
+ `SERVER_TYPE` and `SERVER_ID` are used to build the S3 filename and are included in the
58
+ log payload for S3 and Kinesis.
59
+ If `global.serverType` is set, it overrides `SERVER_TYPE`.
60
+ If `global.serverId` is set, it overrides `SERVER_ID`.
59
61
 
60
62
  **Kind**: global function
61
- **Returns**: <code>object</code> - configuration - logger configuration.
63
+ **Returns**: <code>object</code> - configuration - Logger configuration.
62
64
 
63
65
  ## Synopsis ##
64
66
 
@@ -4,97 +4,82 @@ import {
4
4
  ALL_MODES,
5
5
  AWS_KINESIS,
6
6
  AWS_S3,
7
- DEFAULT_ENV,
8
- DEFAULT_EXIT_DELAY,
9
- DEFAULT_FILTER_FILE,
10
- DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT,
11
- DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
12
- DEFAULT_KINESIS_MAX_EVENTS,
13
- DEFAULT_KINESIS_MAX_SIZE,
14
- DEFAULT_KINESIS_TIMEOUT,
15
- DEFAULT_LEVEL,
16
- DEFAULT_MODE,
17
- DEFAULT_NO_STACK,
18
- DEFAULT_S3_MAX_EVENTS,
19
- DEFAULT_S3_MAX_SIZE,
20
- DEFAULT_S3_TIMEOUT,
7
+ DEFAULT,
21
8
  NONE_MODE,
22
9
  SUMOLOGIC,
23
10
  } from '../lib/common.js';
24
11
  import difference from 'lodash.difference';
25
- import fs from 'fs';
26
12
  import isNil from 'lodash.isnil';
27
13
  import isUndefined from 'lodash.isundefined';
28
- import process from 'process';
14
+ import process from 'node:process';
15
+ import { readFileSync } from 'node:fs';
29
16
  import split from 'lodash.split';
30
17
 
31
18
  const DECIMAL = 10;
32
- const EXISTING_ERRORS = 1;
33
- const NO_MODE = 0;
34
- const KNOWN_MODE = 0;
35
- const SINGLE_MODE = 1;
36
19
 
37
20
  /**
38
21
  *
39
- * logger Configuration.
22
+ * Logger configuration.
40
23
  *
41
24
  * @function config
42
- * @return {object} configuration - logger configuration.
43
- * @description The following environment variables are needed to configure logger:
25
+ * @return {object} configuration - Logger configuration.
26
+ * @description The following environment variables are used to configure the logger:
44
27
  *
45
28
  * | Env variable name | Description | Default | Comments |
46
29
  * | ----------------- | ----------- | ------- | -------- |
47
- * | SERVER_TYPE | Type of the server that is logged | null |
48
- * | SERVER_ID | Id of the server that is logged | null |
49
- * | NODE_ENV | Environment of the running instance | local |
50
- * | LOG_LEVEL | Log level of the running instance | debug |
51
- * | CONSOLE_LEVEL | Log level for the console of the running instance | debug |
52
- * | FILTER_FILE | Filename containing filter rules | null |
53
- * | EXIT_DELAY | Delay when exiting gracefully | 2000 | in millisecond
54
- * | NO_STACK | Indicator to log the call stack on all log messages | no |
55
- * | LOG_MODE | String with comma separated words defining the log mode for the running instance | sumologic | (enum: awsS3, awsKinesis, sumologic, all, none)
30
+ * | SERVER_TYPE | Type of the server being logged | null | |
31
+ * | SERVER_ID | ID of the server being logged | null | |
32
+ * | NODE_ENV | Environment of the running instance | local | |
33
+ * | LOG_LEVEL | Log level for the running instance | debug | |
34
+ * | CONSOLE_LEVEL | Console log level | debug | |
35
+ * | FILTER_FILE | Filename containing filter rules | null | |
36
+ * | EXIT_DELAY | Delay before exiting gracefully | 2000 | in milliseconds |
37
+ * | NO_STACK | Whether to include call stacks in all log messages | no | expected: yes/no |
38
+ * | LOG_MODE | Comma-separated list defining the log mode/backends | sumologic | enum: awsS3, awsKinesis, sumologic, all, none |
56
39
  *
57
- * If `LOG_MODE` includes `sumologic` the following environment variables are needed:
40
+ * If `LOG_MODE` includes `sumologic`, the following environment variables are required:
58
41
  *
59
42
  * | Env variable name | Description | Default | Comments |
60
43
  * | ----------------- | ----------- | ------- | -------- |
61
- * | SUMO_LOGIC_ENDPOINT | URL of the sumologic collector
62
- * | SUMO_LOGIC_COLLECTOR_CODE | Code of the sumologic collector
44
+ * | SUMO_LOGIC_ENDPOINT | URL of the Sumo Logic collector | | |
45
+ * | SUMO_LOGIC_COLLECTOR_CODE | Code of the Sumo Logic collector | | |
63
46
  *
64
- * If `LOG_MODE` includes `awsKinesis` the following environment variables are needed:
47
+ * If `LOG_MODE` includes `awsKinesis`, the following environment variables are required:
65
48
  *
66
49
  * | Env variable name | Description | Default | Comments |
67
50
  * | ----------------- | ----------- | ------- | -------- |
68
- * | KINESIS_AWS_STREAM_NAME_INFO | Name of the stream for info level logs
69
- * | KINESIS_AWS_STREAM_NAME_ERROR | Name of the stream for error level logs
70
- * | KINESIS_AWS_STREAM_NAME_OTHER | Name of the stream for any other level logs
71
- * | KINESIS_AWS_REGION | Region of the stream
72
- * | KINESIS_AWS_TIMEOUT | Maximum time before flushing | 1000 | in millisecond
73
- * | KINESIS_AWS_MAX_SIZE | Maximum size of the accumulated logs before flushing | 5 | in mByte
74
- * | KINESIS_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000 |
75
- * | KINESIS_AWS_ACCESS_KEY_ID | Access key id of the stream
76
- * | KINESIS_AWS_SECRET_ACCESS_KEY | Access key secret of the stream
77
- * | KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT | Socket timeout for the http handler | 5000 | in millisecond
78
- * | KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT | Connection timeout for the http handler | 5000 | in millisecond
51
+ * | KINESIS_AWS_STREAM_NAME_INFO | Stream name for `info` level logs | | |
52
+ * | KINESIS_AWS_STREAM_NAME_ERROR | Stream name for `error` level logs | | |
53
+ * | KINESIS_AWS_STREAM_NAME_OTHER | Stream name for any other level | | |
54
+ * | KINESIS_AWS_REGION | AWS region of the stream | | |
55
+ * | KINESIS_AWS_TIMEOUT | Maximum time before flushing | 1000 | in millisecond |
56
+ * | KINESIS_AWS_MAX_SIZE | Maximum accumulated log size before flushing | 5 | in MB |
57
+ * | KINESIS_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000 | |
58
+ * | KINESIS_AWS_MAX_RETRIES | Maximum connection retries | 4 | |
59
+ * | KINESIS_AWS_ACCESS_KEY_ID | AWS access key ID | | |
60
+ * | KINESIS_AWS_SECRET_ACCESS_KEY | AWS secret access key | | |
61
+ * | KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT | HTTP handler socket timeout | 5000 | in millisecond |
62
+ * | KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT | HTTP handler connection timeout | 5000 | in millisecond |
79
63
  *
80
- * If `LOG_MODE` includes `awsS3` the following environment variables are needed:
64
+ * If `LOG_MODE` includes `awsS3`, the following environment variables are required:
81
65
  *
82
66
  * | Env variable name | Description | Default | Comments |
83
67
  * | ----------------- | ----------- | ------- | -------- |
84
- * | S3_AWS_BUCKET_NAME | Name of the bucket for storing the logs
85
- * | S3_AWS_REGION | Region of the bucket
86
- * | S3_AWS_TIMEOUT | Maximum time before flushing | 5 | in minute
87
- * | S3_AWS_MAX_SIZE | Maximum size of the accumulated logs before flushing | 5 | in mByte
88
- * | S3_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000 |
89
- * | S3_AWS_ACCESS_KEY_ID | Access key id of the bucket
90
- * | S3_AWS_SECRET_ACCESS_KEY | Access key secret of the bucket
68
+ * | S3_AWS_BUCKET_NAME | S3 bucket name for storing logs | | |
69
+ * | S3_AWS_REGION | AWS region of the bucket | | |
70
+ * | S3_AWS_TIMEOUT | Maximum time before flushing | 5 | in minute |
71
+ * | S3_AWS_MAX_SIZE | Maximum accumulated log size before flushing | 5 | in MB |
72
+ * | S3_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000 | |
73
+ * | S3_AWS_ACCESS_KEY_ID | AWS access key ID | | |
74
+ * | S3_AWS_SECRET_ACCESS_KEY | AWS secret access key | | |
91
75
  *
92
- * When `LOG_MODE` is `none` the logs will only be on `console`.
93
- * When `LOG_MODE` is `all` LOG_MODE will be set to `sumologic, awsS3`.
76
+ * When `LOG_MODE` is `none`, logs are written to the console only.
77
+ * When `LOG_MODE` is `all`, it is equivalent to `sumologic,awsS3`.
94
78
  *
95
- * The SERVER_TYPE and SERVER_ID are used to create the S3 filename and are inserted in the payload of the log for S3 and Kinesis.
96
- * If `global.serverType` is set, this value is used over SERVER_TYPE.
97
- * If `global.serverType` is set, the value of `global.serverId` is used over `SERVER_ID`.
79
+ * `SERVER_TYPE` and `SERVER_ID` are used to build the S3 filename and are included in the
80
+ * log payload for S3 and Kinesis.
81
+ * If `global.serverType` is set, it overrides `SERVER_TYPE`.
82
+ * If `global.serverId` is set, it overrides `SERVER_ID`.
98
83
  */
99
84
 
100
85
  const checkConfig = (config) => {
@@ -110,7 +95,7 @@ const checkConfig = (config) => {
110
95
  };
111
96
 
112
97
  traverseNodeSync(config, 'configuration');
113
- if (errs.length > EXISTING_ERRORS) {
98
+ if (errs.length > 1) {
114
99
  throw new Error(`Missing values for ${errs}`);
115
100
  }
116
101
  };
@@ -120,9 +105,9 @@ const checkMode = (mode) => {
120
105
 
121
106
  if (mode) {
122
107
  logMode = split(mode.trim(), /\s*,\s*/u);
123
- if (logMode.length === NO_MODE) throw new Error('Invalid LOG_MODE: cannot be an empty array');
124
- if (difference(logMode, ALL_MODES).length !== KNOWN_MODE) throw new Error(`Invalid items in LOG_MODE: ${mode}`);
125
- if (logMode.includes(NONE_MODE) && logMode.length !== SINGLE_MODE) throw new Error(`Cannot have multiple modes when ${NONE_MODE} is selected`);
108
+ if (logMode.length === 0) throw new Error('Invalid LOG_MODE: cannot be an empty array');
109
+ if (difference(logMode, ALL_MODES).length !== 0) throw new Error(`Invalid items in LOG_MODE: ${mode}`);
110
+ if (logMode.includes(NONE_MODE) && logMode.length !== 1) throw new Error(`Cannot have multiple modes when ${NONE_MODE} is selected`);
126
111
  if (logMode.includes(ALL_MODE)) logMode = [SUMOLOGIC, AWS_S3]; // legacy support
127
112
  }
128
113
  return logMode;
@@ -133,18 +118,18 @@ const configuration = {
133
118
  type: process.env.SERVER_TYPE || null,
134
119
  id: process.env.SERVER_ID || null,
135
120
  },
136
- env: process.env.NODE_ENV || DEFAULT_ENV,
121
+ env: process.env.NODE_ENV || DEFAULT.ENV,
137
122
  level: {
138
- log: process.env.LOG_LEVEL || DEFAULT_LEVEL,
139
- console: process.env.CONSOLE_LEVEL || DEFAULT_LEVEL,
123
+ log: process.env.LOG_LEVEL || DEFAULT.LEVEL,
124
+ console: process.env.CONSOLE_LEVEL || DEFAULT.LEVEL,
140
125
  },
141
126
  filter: {
142
- file: process.env.FILTER_FILE || DEFAULT_FILTER_FILE,
127
+ file: process.env.FILTER_FILE || DEFAULT.FILTER_FILE,
143
128
  },
144
- exitDelay: parseInt(process.env.EXIT_DELAY, DECIMAL) || DEFAULT_EXIT_DELAY, // in millisecond
145
- noStack: process.env.NO_STACK || DEFAULT_NO_STACK,
129
+ exitDelay: parseInt(process.env.EXIT_DELAY, DECIMAL) || DEFAULT.EXIT_DELAY, // in millisecond
130
+ noStack: process.env.NO_STACK || DEFAULT.NO_STACK,
146
131
  };
147
- configuration.mode = checkMode(process.env.LOG_MODE) || DEFAULT_MODE;
132
+ configuration.mode = checkMode(process.env.LOG_MODE) || DEFAULT.MODE;
148
133
 
149
134
  if (configuration.mode.includes(SUMOLOGIC)) {
150
135
  configuration[SUMOLOGIC] = {
@@ -158,12 +143,13 @@ if (configuration.mode.includes(AWS_KINESIS)) {
158
143
  streamNameError: process.env.KINESIS_AWS_STREAM_NAME_ERROR,
159
144
  streamNameOther: process.env.KINESIS_AWS_STREAM_NAME_OTHER,
160
145
  region: process.env.KINESIS_AWS_REGION,
161
- timeout: parseInt(process.env.KINESIS_AWS_TIMEOUT, DECIMAL) || DEFAULT_KINESIS_TIMEOUT, // in millisecond
162
- maxSize: parseInt(process.env.KINESIS_AWS_MAX_SIZE, DECIMAL) || DEFAULT_KINESIS_MAX_SIZE, // in mByte
163
- maxEvents: parseInt(process.env.KINESIS_AWS_MAX_EVENTS, DECIMAL) || DEFAULT_KINESIS_MAX_EVENTS,
146
+ timeout: parseInt(process.env.KINESIS_AWS_TIMEOUT, DECIMAL) || DEFAULT.KINESIS_TIMEOUT, // in millisecond
147
+ maxSize: parseInt(process.env.KINESIS_AWS_MAX_SIZE, DECIMAL) || DEFAULT.KINESIS_MAX_SIZE, // in mByte
148
+ maxEvents: parseInt(process.env.KINESIS_AWS_MAX_EVENTS, DECIMAL) || DEFAULT.KINESIS_MAX_EVENTS,
149
+ maxRetries: parseInt(process.env.KINESIS_AWS_MAX_RETRIES, DECIMAL) || DEFAULT.KINESIS_MAX_RETRIES,
164
150
  httpOptions: {
165
- socketTimeout: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT, DECIMAL) || DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
166
- connectionTimeout: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT, DECIMAL) || DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT,
151
+ socketTimeout: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT, DECIMAL) || DEFAULT.KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
152
+ connectionTimeout: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT, DECIMAL) || DEFAULT.KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT,
167
153
  },
168
154
  };
169
155
 
@@ -174,9 +160,9 @@ if (configuration.mode.includes(AWS_S3)) {
174
160
  configuration[AWS_S3] = {
175
161
  bucketname: process.env.S3_AWS_BUCKET_NAME,
176
162
  region: process.env.S3_AWS_REGION,
177
- timeout: parseInt(process.env.S3_AWS_TIMEOUT, DECIMAL) || DEFAULT_S3_TIMEOUT, // in minute
178
- maxSize: parseInt(process.env.S3_AWS_MAX_SIZE, DECIMAL) || DEFAULT_S3_MAX_SIZE, // in mByte
179
- maxEvents: parseInt(process.env.S3_AWS_MAX_EVENTS, DECIMAL) || DEFAULT_S3_MAX_EVENTS,
163
+ timeout: parseInt(process.env.S3_AWS_TIMEOUT, DECIMAL) || DEFAULT.S3_TIMEOUT, // in minute
164
+ maxSize: parseInt(process.env.S3_AWS_MAX_SIZE, DECIMAL) || DEFAULT.S3_MAX_SIZE, // in mByte
165
+ maxEvents: parseInt(process.env.S3_AWS_MAX_EVENTS, DECIMAL) || DEFAULT.S3_MAX_EVENTS,
180
166
  };
181
167
 
182
168
  if (!isNil(process.env.S3_AWS_ACCESS_KEY_ID)) configuration[AWS_S3].accessKeyId = process.env.S3_AWS_ACCESS_KEY_ID;
@@ -187,10 +173,10 @@ let filterConfig = [];
187
173
 
188
174
  if (filter.file) {
189
175
  try {
190
- filterConfig = JSON.parse(fs.readFileSync(filter.file).toString());
176
+ filterConfig = JSON.parse(readFileSync(filter.file).toString());
191
177
  }
192
178
  catch (err) {
193
- throw new Error(`Invalid file for logger config: ${filter.file}, error: ${err.message}`);
179
+ throw new Error(`Invalid file for logger config: ${filter.file}`, { cause: err });
194
180
  }
195
181
  }
196
182
  filter.config = filterConfig;
package/eslint.config.js CHANGED
@@ -10,6 +10,9 @@ const MAX_LINES_IN_FUNCTION = 150;
10
10
  const MAX_STATEMENTS_IN_FUNCTION = 45;
11
11
  const MIN_KEYS_IN_OBJECT = 10;
12
12
  const MAX_COMPLEXITY = 30;
13
+ const ECMA_VERSION = 2022;
14
+ const MAX_DEPTH = 6;
15
+ const ALLOWED_CONSTANTS = [0, 1, -1];
13
16
 
14
17
  export default [
15
18
  {
@@ -23,7 +26,7 @@ export default [
23
26
  processDoc,
24
27
  },
25
28
  languageOptions: {
26
- ecmaVersion: 2022,
29
+ ecmaVersion: ECMA_VERSION,
27
30
  globals: {
28
31
  console: 'readonly',
29
32
  describe: 'readonly',
@@ -35,6 +38,7 @@ export default [
35
38
  rules: {
36
39
  '@stylistic/brace-style': ['warn', 'stroustrup', { allowSingleLine: true }],
37
40
  '@stylistic/line-comment-position': ['off'],
41
+ '@stylistic/max-len': ['warn', MAX_LENGTH_LINE, { ignoreComments: true, ignoreStrings: true, ignoreRegExpLiterals: true }],
38
42
  '@stylistic/semi': ['error', 'always'],
39
43
  'capitalized-comments': ['off'],
40
44
  'complexity': ['error', MAX_COMPLEXITY],
@@ -44,20 +48,22 @@ export default [
44
48
  'import/no-unresolved': ['error', { amd: true, caseSensitiveStrict: true, commonjs: true }],
45
49
  'init-declarations': ['off'],
46
50
  'linebreak-style': ['off'],
47
- 'max-len': ['warn', MAX_LENGTH_LINE, { ignoreComments: true }],
48
- 'max-lines': ['warn', { max: MAX_LINES_IN_FILES, skipComments: true }],
49
- 'max-lines-per-function': ['warn', { max: MAX_LINES_IN_FUNCTION, skipComments: true }],
51
+ 'max-depth': ['error', MAX_DEPTH],
52
+ 'max-lines': ['warn', { max: MAX_LINES_IN_FILES, skipComments: true, skipBlankLines: true }],
53
+ 'max-lines-per-function': ['warn', { max: MAX_LINES_IN_FUNCTION, skipComments: true, skipBlankLines: true }],
50
54
  'max-params': ['error', MAX_FUNCTION_PARAMETERS],
51
55
  'max-statements': ['warn', MAX_STATEMENTS_IN_FUNCTION],
52
- 'no-confusing-arrow': ['off'], // arrow isnt confusing
56
+ 'no-confusing-arrow': ['off'],
53
57
  'no-inline-comments': ['off'],
58
+ 'no-magic-numbers': ['error', { ignore: ALLOWED_CONSTANTS, enforceConst: true, detectObjects: true }],
54
59
  'no-process-env': ['error'],
55
60
  'no-ternary': ['off'],
56
61
  'no-undefined': ['off'],
57
62
  'one-var': ['error', 'never'],
58
63
  'processDoc/validate-document-env': ['error'],
59
64
  'quotes': ['warn', 'single'],
60
- 'sort-keys': ['error', 'asc', { caseSensitive: true, minKeys: MIN_KEYS_IN_OBJECT, natural: false }],
65
+ 'sort-imports': ['error', { allowSeparatedGroups: true }],
66
+ 'sort-keys': ['error', 'asc', { caseSensitive: true, minKeys: MIN_KEYS_IN_OBJECT, natural: false, allowLineSeparatedGroups: true }],
61
67
  },
62
68
  },
63
69
  ];
package/index.js CHANGED
@@ -18,13 +18,12 @@ import {
18
18
  format,
19
19
  transports,
20
20
  } from 'winston';
21
-
22
21
  import AwsKinesis from './lib/awsKinesisTransport.js';
23
22
  import AwsS3 from './lib/awsS3Transport.js';
24
23
  import Sumologic from './lib/sumologicTransport.js';
25
24
  import config from './configuration/config.js';
26
- import process from 'process';
27
- import { setTimeout } from 'timers';
25
+ import process from 'node:process';
26
+ import { setTimeout } from 'node:timers';
28
27
 
29
28
  let sumo;
30
29
  let awsS3;
@@ -94,6 +93,7 @@ if (config.mode.includes(AWS_KINESIS)) {
94
93
  },
95
94
  level: config.level.log,
96
95
  maxEvents: config[AWS_KINESIS].maxEvents,
96
+ maxRetries: config[AWS_KINESIS].maxRetries,
97
97
  maxSize: config[AWS_KINESIS].maxSize,
98
98
  region: config[AWS_KINESIS].region,
99
99
  secretAccessKey: config[AWS_KINESIS].secretAccessKey,
@@ -4,9 +4,11 @@ import {
4
4
  ERROR,
5
5
  INFO,
6
6
  LOG,
7
+ MEGA,
7
8
  MESSAGE,
8
9
  OTHER,
9
10
  PARTITION_KEY,
11
+ SYSTEM_ERROR,
10
12
  UNKNOWN_ID,
11
13
  UNKNOWN_TYPE,
12
14
  WARN,
@@ -18,16 +20,14 @@ import {
18
20
  import {
19
21
  setImmediate,
20
22
  setInterval,
21
- } from 'timers';
22
- import { Buffer } from 'buffer';
23
+ } from 'node:timers';
24
+ import { Buffer } from 'node:buffer';
23
25
  import { NodeHttpHandler } from '@smithy/node-http-handler';
24
26
  import Promise from 'bluebird';
25
27
  import Transport from 'winston-transport';
26
28
 
27
29
  const RANDOM_MIN = 0;
28
30
  const RANDOM_LIMIT = 100;
29
- const MEGA = 1048576; // 2^20 conversion to mega
30
- const SYSTEM_ERROR = 500;
31
31
 
32
32
  const events = {};
33
33
 
@@ -55,7 +55,7 @@ export default class AwsKinesis extends Transport {
55
55
  };
56
56
  }
57
57
 
58
- this.kinesisClientConfig.maxAttempts = 5;
58
+ this.kinesisClientConfig.maxAttempts = options.maxRetries + 1;
59
59
  this.kinesisClientConfig.requestHandler = new NodeHttpHandler(
60
60
  {
61
61
  connectionTimeout: options.httpOptions.connectionTimeout,
@@ -2,7 +2,9 @@ import {
2
2
  AWS_S3,
3
3
  CLIENTS,
4
4
  LOG,
5
+ MEGA,
5
6
  MESSAGE,
7
+ SYSTEM_ERROR,
6
8
  UNKNOWN_ID,
7
9
  UNKNOWN_TYPE,
8
10
  WARN,
@@ -14,18 +16,14 @@ import {
14
16
  import {
15
17
  setImmediate,
16
18
  setInterval,
17
- } from 'timers';
19
+ } from 'node:timers';
18
20
  import Promise from 'bluebird';
19
21
  import Transport from 'winston-transport';
20
22
 
21
23
  const events = {};
22
24
  const typeEvents = {};
23
25
 
24
- const INCR = 1;
25
- const NONE = 0;
26
- const MEGA = 1048576; // 2^20 conversion to mega
27
26
  const MILLI_MIN = 60000; // 1000*60 conversion to minute
28
- const SYSTEM_ERROR = 500;
29
27
 
30
28
  export default class AwsS3 extends Transport {
31
29
  constructor(options = {}) {
@@ -71,7 +69,7 @@ export default class AwsS3 extends Transport {
71
69
  put(data, lvl, date) {
72
70
  const command = new PutObjectCommand({
73
71
  Bucket: this.bucketname,
74
- Key: `${lvl}/${this.server}/${date.getFullYear()}/${date.getMonth() + INCR}/${date.getDate()}/${date.toISOString()}.json`,
72
+ Key: `${lvl}/${this.server}/${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}/${date.toISOString()}.json`,
75
73
  Body: JSON.stringify(data),
76
74
  });
77
75
 
@@ -95,13 +93,13 @@ export default class AwsS3 extends Transport {
95
93
  return Promise.map(Object.keys(data), sType => Promise.each(Object.keys(data[sType]), (sId) => {
96
94
  const command = new PutObjectCommand({
97
95
  Bucket: this.bucketname,
98
- Key: `${lvl}/${sType}/${sId}/${date.getFullYear()}/${date.getMonth() + INCR}/${date.getDate()}/${date.toISOString()}.json`,
96
+ Key: `${lvl}/${sType}/${sId}/${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}/${date.toISOString()}.json`,
99
97
  Body: JSON.stringify(data[sType][sId]),
100
98
  });
101
99
 
102
100
  return this.s3.send(command)
103
101
  .then(() => {
104
- count += INCR;
102
+ count += 1;
105
103
  })
106
104
  .catch(err => errors.push({
107
105
  data: data[sType][sId],
@@ -117,8 +115,8 @@ export default class AwsS3 extends Transport {
117
115
  const { count, errors } = result;
118
116
  const errorCount = errors.length;
119
117
 
120
- if (errorCount === NONE) return this.emit(LOG, { message: `${count} logs sent to ${AWS_S3}` });
121
- if (count === NONE) {
118
+ if (errorCount === 0) return this.emit(LOG, { message: `${count} logs sent to ${AWS_S3}` });
119
+ if (count === 0) {
122
120
  return this.emit(WARN, {
123
121
  errors,
124
122
  nblogs: errorCount,
@@ -161,8 +159,8 @@ export default class AwsS3 extends Transport {
161
159
  const { count, errors } = result;
162
160
  const errorCount = errors.length;
163
161
 
164
- if (errorCount === NONE) return this.emit(LOG, { message: `${count} logs sent to ${AWS_S3}` });
165
- if (count === NONE) {
162
+ if (errorCount === 0) return this.emit(LOG, { message: `${count} logs sent to ${AWS_S3}` });
163
+ if (count === 0) {
166
164
  return this.emit(WARN, {
167
165
  errors,
168
166
  nblogs: errorCount,
package/lib/common.js CHANGED
@@ -1,29 +1,32 @@
1
+ /* eslint-disable no-magic-numbers */
1
2
  const ENV_DEV = ['development', 'dev'];
2
3
  const ENV_LOCAL = 'local';
3
4
 
4
- const DEFAULT_LEVEL = 'debug';
5
- const DEFAULT_ENV = ENV_LOCAL;
6
- const DEFAULT_FILTER_FILE = null;
7
-
8
5
  const ALL_MODE = 'all'; // legacy support
9
6
  const NONE_MODE = 'none';
10
7
  const AWS_S3 = 'awsS3';
11
8
  const SUMOLOGIC = 'sumologic';
12
9
  const AWS_KINESIS = 'awsKinesis';
13
- const DEFAULT_MODE = [NONE_MODE];
14
10
  const ALL_MODES = [AWS_S3, SUMOLOGIC, AWS_KINESIS, ALL_MODE, NONE_MODE];
15
11
 
16
- const DEFAULT_S3_MAX_SIZE = 5; // max size of the data before sending to S3, in mByte
17
- const DEFAULT_S3_MAX_EVENTS = 1000; // max number of events before sending to S3
18
- const DEFAULT_S3_TIMEOUT = 5; // max time before sending events to S3, in minute
19
- const DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT = 5000; // socket timeout for the http handler, in millisecond
20
- const DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT = 5000; // connection timeout for the http handler, in millisecond
21
- const DEFAULT_KINESIS_MAX_SIZE = 5; // max size of the data before sending to Kinesis, in mByte
22
- const DEFAULT_KINESIS_MAX_EVENTS = 1000; // max number of events before sending to Kinesis
23
- const DEFAULT_KINESIS_TIMEOUT = 1000; // max time before sending events to Kinesis, in millisecond
12
+ const DEFAULT = {
13
+ ENV: ENV_LOCAL,
14
+ FILTER_FILE: null,
15
+ LEVEL: 'debug',
16
+ MODE: [NONE_MODE],
17
+ NO_STACK: 'yes',
24
18
 
25
- const DEFAULT_EXIT_DELAY = 2000; // delay for flushing the transports and exiting, in millisecond
26
- const DEFAULT_NO_STACK = 'yes';
19
+ EXIT_DELAY: 2000, // delay for flushing the transports and exiting, in millisecond
20
+ KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT: 5000, // connection timeout for the http handler, in millisecond
21
+ KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT: 5000, // socket timeout for the http handler, in millisecond
22
+ KINESIS_MAX_EVENTS: 1000, // max number of events before sending to Kinesis
23
+ KINESIS_MAX_RETRIES: 4, // max retries to connect to Kinesis
24
+ KINESIS_MAX_SIZE: 5, // max size of the data before sending to Kinesis, in mByte
25
+ KINESIS_TIMEOUT: 1000, // max time before sending events to Kinesis, in millisecond
26
+ S3_MAX_EVENTS: 1000, // max number of events before sending to S3
27
+ S3_MAX_SIZE: 5, // max size of the data before sending to S3, in mByte
28
+ S3_TIMEOUT: 5, // max time before sending events to S3, in minute
29
+ };
27
30
 
28
31
  const SPLAT = Symbol.for('splat');
29
32
  const LEVEL = Symbol.for('level');
@@ -43,40 +46,44 @@ const INFO = 'info';
43
46
  const ERROR = 'error';
44
47
  const OTHER = 'other';
45
48
 
49
+ const UNAUTHORIZED_ERROR = 401;
50
+ const NOT_FOUND_ERROR = 404;
51
+ const SYSTEM_ERROR = 500;
52
+
53
+ const START_TIMEOUT = 30000; // in millisecond
54
+ const FLUSH_TIMEOUT = 1000; // in millisecond
55
+ const OK_EXIT = 0;
56
+
57
+ const MEGA = 1048576; // 2^20 conversion to mega
58
+
46
59
  export {
47
60
  ALL_MODE,
48
61
  ALL_MODES,
49
62
  AWS_KINESIS,
50
63
  AWS_S3,
51
64
  CLIENTS,
52
- DEFAULT_ENV,
53
- DEFAULT_EXIT_DELAY,
54
- DEFAULT_FILTER_FILE,
55
- DEFAULT_KINESIS_MAX_EVENTS,
56
- DEFAULT_KINESIS_MAX_SIZE,
57
- DEFAULT_KINESIS_TIMEOUT,
58
- DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
59
- DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT,
60
- DEFAULT_LEVEL,
61
- DEFAULT_MODE,
62
- DEFAULT_NO_STACK,
63
- DEFAULT_S3_MAX_EVENTS,
64
- DEFAULT_S3_MAX_SIZE,
65
- DEFAULT_S3_TIMEOUT,
65
+ DEFAULT,
66
66
  ENV_DEV,
67
67
  ENV_LOCAL,
68
68
  ERROR,
69
69
  FLUSH,
70
70
  FLUSH_EXIT,
71
+ FLUSH_TIMEOUT,
71
72
  INFO,
72
73
  LEVEL,
73
74
  LOG,
75
+ MEGA,
74
76
  MESSAGE,
75
77
  NONE_MODE,
78
+ NOT_FOUND_ERROR,
79
+ OK_EXIT,
76
80
  OTHER,
77
81
  PARTITION_KEY,
78
82
  SPLAT,
83
+ START_TIMEOUT,
79
84
  SUMOLOGIC,
85
+ SYSTEM_ERROR,
86
+ UNAUTHORIZED_ERROR,
80
87
  UNKNOWN_TYPE,
81
88
  UNKNOWN_ID,
82
89
  WARN,
package/lib/stackLib.js CHANGED
@@ -1,8 +1,6 @@
1
- import crypto from 'crypto';
2
- import {
3
- fileURLToPath,
4
- } from 'url';
5
- import path from 'path';
1
+ import { basename } from 'node:path';
2
+ import { createHash } from 'node:crypto';
3
+ import { fileURLToPath } from 'node:url';
6
4
  import reject from 'lodash.reject';
7
5
 
8
6
  // Stack trace format :
@@ -43,10 +41,10 @@ const parseStack = (newError) => {
43
41
  path: stackParts[PATH],
44
42
  line: stackParts[LINE],
45
43
  pos: stackParts[POSITION],
46
- file: path.basename(stackParts[PATH]),
44
+ file: basename(stackParts[PATH]),
47
45
  stack: `${SHIFT}${truncatedList.join('\n').trimStart()}`,
48
46
  };
49
- stackInfo.hash = crypto.createHash('sha256', SECRET)
47
+ stackInfo.hash = createHash('sha256', SECRET)
50
48
  .update(stackInfo.stack)
51
49
  .digest('hex');
52
50
  // this is a hash of the stacktrace for easier searching for the stacktrace
@@ -1,21 +1,18 @@
1
1
  import {
2
2
  CLIENTS,
3
3
  LOG,
4
+ NOT_FOUND_ERROR,
4
5
  SPLAT,
5
6
  SUMOLOGIC,
7
+ SYSTEM_ERROR,
8
+ UNAUTHORIZED_ERROR,
6
9
  UNKNOWN_ID,
7
10
  UNKNOWN_TYPE,
8
11
  WARN,
9
12
  } from './common.js';
10
13
  import Transport from 'winston-transport';
11
14
  import axios from 'axios';
12
- import {
13
- setImmediate,
14
- } from 'timers';
15
-
16
- const UNAUTHORIZED_ERROR = 401;
17
- const NOTFOUND_ERROR = 404;
18
- const SYSTEM_ERROR = 500;
15
+ import { setImmediate } from 'node:timers';
19
16
 
20
17
  export default class Sumo extends Transport {
21
18
  constructor(options = {}) {
@@ -65,7 +62,7 @@ export default class Sumo extends Transport {
65
62
  resp.error.message = `invalid ${SUMOLOGIC} code`;
66
63
  resp.code = this.code;
67
64
  }
68
- else if (status === NOTFOUND_ERROR) resp.error.message = `invalid ${SUMOLOGIC} endpoint`;
65
+ else if (status === NOT_FOUND_ERROR) resp.error.message = `invalid ${SUMOLOGIC} endpoint`;
69
66
  else resp.error.message = `could not log to ${SUMOLOGIC}`;
70
67
  return this.emit(WARN, resp);
71
68
  });
@@ -2,24 +2,24 @@
2
2
  import bodyParser from 'body-parser';
3
3
  import express from 'express';
4
4
 
5
- const INCR = 1;
6
-
7
5
  let i = 0;
6
+ const MOCK_PORT = 9000;
7
+ const CREATED_RESPONSE = 201;
8
8
 
9
9
  const app = express();
10
10
  const config = {
11
- port: 9000,
11
+ port: MOCK_PORT,
12
12
  base: '/checkthat',
13
13
  };
14
14
 
15
15
  app.use(bodyParser.json());
16
16
  app.post(`${config.base}`, (req, res) => {
17
- i += INCR;
17
+ i += 1;
18
18
  console.log('Recieved a POST:', i);
19
19
  // console.log('headers:', req.headers)
20
20
  console.log(req.body);
21
21
 
22
- res.statusCode = 201;
22
+ res.statusCode = CREATED_RESPONSE;
23
23
  res.send(req.body);
24
24
  });
25
25
 
@@ -1,9 +1,8 @@
1
1
  /* eslint-disable no-console */
2
2
  import '../test/testEnv.js';
3
- import clone from 'lodash.clone';
4
3
  import { getCorrelationId } from '@mimik/request-helper';
5
4
  import logger from '../index.js';
6
- import process from 'process';
5
+ import process from 'node:process';
7
6
 
8
7
  const user = {
9
8
  name: 'a name',
@@ -28,7 +27,7 @@ logger.debug('This is a test with error', { user }, correlationId);
28
27
  logger.error('This is a test, error', { user }, correlationId);
29
28
 
30
29
  stdin.addListener('data', () => {
31
- const clonedObject = clone(user);
30
+ const clonedObject = { ...user };
32
31
 
33
32
  clonedObject.index = 'manual';
34
33
  console.log('manual logging');
@@ -1,4 +1,5 @@
1
1
  import '../test/testEnv';
2
+ import { SYSTEM_ERROR } from '../lib/common.js';
2
3
  import logger from '../index.js';
3
4
 
4
5
  const ISSUE_EXIT = 1;
@@ -16,7 +17,7 @@ const complexObject = {
16
17
  complexObject.propG = complexObject;
17
18
  const error = new Error('an error');
18
19
  error.name = 'this is a complex error';
19
- error.statusCode = 500;
20
+ error.statusCode = SYSTEM_ERROR;
20
21
  error.title = 'System error';
21
22
 
22
23
  logger.info('this is a test', { user: complexObject }, '12345678');
@@ -1,12 +1,10 @@
1
1
  /* eslint-disable no-console */
2
2
  import '../test/testEnv.js';
3
3
  import Promise from 'bluebird';
4
- import clone from 'lodash.clone';
5
4
  import { getCorrelationId } from '@mimik/request-helper';
6
5
  import logger from '../index.js';
7
6
 
8
7
  const MAX_ITEMS = 100000;
9
- const INCR = 1;
10
8
 
11
9
  const complexObject = {
12
10
  key: 'property a',
@@ -28,8 +26,8 @@ const object = {
28
26
  };
29
27
  const objects = [];
30
28
 
31
- for (let i = 0; i < MAX_ITEMS; i += INCR) {
32
- const clonedObject = clone(object);
29
+ for (let i = 0; i < MAX_ITEMS; i += 1) {
30
+ const clonedObject = { ...object };
33
31
 
34
32
  clonedObject.index = i;
35
33
  objects.push(clonedObject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimik/sumologic-winston-logger",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "Log wrapper for sumo, s3, kinesis and winston",
5
5
  "main": "./index.js",
6
6
  "type": "module",
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@mimik/lib-filters": "^2.0.4",
37
- "@aws-sdk/client-s3": "3.878.0",
38
- "@aws-sdk/client-kinesis": "3.876.0",
39
- "@smithy/node-http-handler": "4.1.1",
40
- "axios": "1.11.0",
37
+ "@aws-sdk/client-s3": "3.888.0",
38
+ "@aws-sdk/client-kinesis": "3.888.0",
39
+ "@smithy/node-http-handler": "4.2.1",
40
+ "axios": "1.12.1",
41
41
  "bluebird": "3.7.2",
42
42
  "lodash.difference": "4.5.0",
43
43
  "lodash.foreach": "4.5.0",
@@ -51,20 +51,19 @@
51
51
  "winston-transport": "4.9.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@eslint/js": "9.34.0",
54
+ "@eslint/js": "9.35.0",
55
55
  "@mimik/eslint-plugin-document-env": "^2.0.8",
56
56
  "@mimik/request-helper": "^2.0.2",
57
- "@stylistic/eslint-plugin": "5.2.3",
57
+ "@stylistic/eslint-plugin": "5.3.1",
58
58
  "body-parser": "2.2.0",
59
59
  "c8": "10.1.3",
60
60
  "chai": "6.0.1",
61
- "eslint": "9.34.0",
61
+ "eslint": "9.35.0",
62
62
  "eslint-plugin-import": "2.32.0",
63
63
  "express": "5.1.0",
64
64
  "husky": "9.1.7",
65
65
  "jsdoc-to-markdown": "9.1.2",
66
- "lodash.clone": "4.5.0",
67
- "mocha": "11.7.1",
66
+ "mocha": "11.7.2",
68
67
  "mochawesome": "7.1.3",
69
68
  "sinon": "21.0.0",
70
69
  "supertest": "7.1.4"
@@ -1,16 +1,13 @@
1
1
  import './testEnv.js';
2
+ import { FLUSH_TIMEOUT, OK_EXIT, START_TIMEOUT } from '../lib/common.js';
2
3
  import { before, describe, it } from 'mocha';
3
4
  import { getCorrelationId } from '@mimik/request-helper';
4
5
  import logger from '../index.js';
5
- import process from 'process';
6
- import { setTimeout } from 'timers';
6
+ import process from 'node:process';
7
+ import { setTimeout } from 'node:timers';
7
8
  import { should } from 'chai';
8
9
  import { stub } from 'sinon';
9
10
 
10
- const START_TIMEOUT = 30000;
11
- const FLUSH_TIMEOUT = 1000;
12
- const OK_EXIT = 0;
13
-
14
11
  const correlationId = getCorrelationId('--sumologic-winston-logger-test--');
15
12
 
16
13
  should();
@@ -1,16 +1,13 @@
1
1
  import './testEnvProdFilter.js';
2
+ import { FLUSH_TIMEOUT, OK_EXIT, START_TIMEOUT } from '../lib/common.js';
2
3
  import { before, describe, it } from 'mocha';
3
4
  import { getCorrelationId } from '@mimik/request-helper';
4
5
  import logger from '../index.js';
5
- import process from 'process';
6
- import { setTimeout } from 'timers';
6
+ import process from 'node:process';
7
+ import { setTimeout } from 'node:timers';
7
8
  import { should } from 'chai';
8
9
  import { stub } from 'sinon';
9
10
 
10
- const START_TIMEOUT = 30000;
11
- const FLUSH_TIMEOUT = 1000;
12
- const OK_EXIT = 0;
13
-
14
11
  const correlationId = getCorrelationId('--sumologic-winston-logger-prod-test--');
15
12
 
16
13
  const user = {
package/test/testEnv.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint no-process-env: "off" */
2
+ import process from 'node:process';
2
3
 
3
- import process from 'process';
4
4
  /**
5
5
  *
6
6
  * Test logger Configuration.
@@ -1,6 +1,6 @@
1
1
  /* eslint no-process-env: "off" */
2
+ import process from 'node:process';
2
3
 
3
- import process from 'process';
4
4
  /**
5
5
  *
6
6
  * Test logger prod with filter Configuration.