@mimik/sumologic-winston-logger 2.1.3 → 2.1.5
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 +12 -11
- package/configuration/config.js +18 -19
- package/eslint.config.js +6 -3
- package/index.js +1 -0
- package/lib/awsKinesisTransport.js +2 -2
- package/lib/awsS3Transport.js +8 -10
- package/lib/common.js +5 -0
- package/manual-test/eventsMock.js +5 -5
- package/manual-test/testLogAndQuit.js +2 -1
- package/manual-test/testManyLogs.js +1 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,15 +5,15 @@ The following environment variables are needed to configure 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
|
|
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
|
|
15
|
-
| NO_STACK |
|
|
16
|
-
| LOG_MODE | String with comma separated words defining the
|
|
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
17
|
|
|
18
18
|
If `LOG_MODE` includes `sumologic` the following environment variables are needed:
|
|
19
19
|
|
|
@@ -32,7 +32,8 @@ If `LOG_MODE` includes `awsKinesis` the following environment variables are need
|
|
|
32
32
|
| KINESIS_AWS_REGION | Region of the stream
|
|
33
33
|
| KINESIS_AWS_TIMEOUT | Maximum time before flushing | 1000 | in millisecond
|
|
34
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
|
|
35
|
+
| KINESIS_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000
|
|
36
|
+
| KINESIS_AWS_MAX_RETRIES | Maximum retries to connect to Kinesis | 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
|
|
38
39
|
| KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT | Socket timeout for the http handler | 5000 | in millisecond
|
|
@@ -46,7 +47,7 @@ If `LOG_MODE` includes `awsS3` the following environment variables are needed:
|
|
|
46
47
|
| S3_AWS_REGION | Region of the bucket
|
|
47
48
|
| S3_AWS_TIMEOUT | Maximum time before flushing | 5 | in minute
|
|
48
49
|
| 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_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000
|
|
50
51
|
| S3_AWS_ACCESS_KEY_ID | Access key id of the bucket
|
|
51
52
|
| S3_AWS_SECRET_ACCESS_KEY | Access key secret of the bucket
|
|
52
53
|
|
package/configuration/config.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT,
|
|
11
11
|
DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
|
|
12
12
|
DEFAULT_KINESIS_MAX_EVENTS,
|
|
13
|
+
DEFAULT_KINESIS_MAX_RETRIES,
|
|
13
14
|
DEFAULT_KINESIS_MAX_SIZE,
|
|
14
15
|
DEFAULT_KINESIS_TIMEOUT,
|
|
15
16
|
DEFAULT_LEVEL,
|
|
@@ -29,10 +30,6 @@ import process from 'process';
|
|
|
29
30
|
import split from 'lodash.split';
|
|
30
31
|
|
|
31
32
|
const DECIMAL = 10;
|
|
32
|
-
const EXISTING_ERRORS = 1;
|
|
33
|
-
const NO_MODE = 0;
|
|
34
|
-
const KNOWN_MODE = 0;
|
|
35
|
-
const SINGLE_MODE = 1;
|
|
36
33
|
|
|
37
34
|
/**
|
|
38
35
|
*
|
|
@@ -44,15 +41,15 @@ const SINGLE_MODE = 1;
|
|
|
44
41
|
*
|
|
45
42
|
* | Env variable name | Description | Default | Comments |
|
|
46
43
|
* | ----------------- | ----------- | ------- | -------- |
|
|
47
|
-
* | SERVER_TYPE | Type of the server that is logged | null
|
|
48
|
-
* | SERVER_ID |Id of the
|
|
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
|
|
54
|
-
* | NO_STACK |
|
|
55
|
-
* | LOG_MODE | String with comma separated words defining the
|
|
44
|
+
* | SERVER_TYPE | Type of the server that is logged | null
|
|
45
|
+
* | SERVER_ID | Id of the server that is logged | null
|
|
46
|
+
* | NODE_ENV | Environment of the running instance | local
|
|
47
|
+
* | LOG_LEVEL | Log level of the running instance | debug
|
|
48
|
+
* | CONSOLE_LEVEL | Log level for the console of the running instance | debug
|
|
49
|
+
* | FILTER_FILE | Filename containing filter rules | null
|
|
50
|
+
* | EXIT_DELAY | Delay when exiting gracefully | 2000 | in millisecond
|
|
51
|
+
* | NO_STACK | Indicator to log the call stack on all log messages | no
|
|
52
|
+
* | LOG_MODE | String with comma separated words defining the log mode for the running instance | sumologic | (enum: awsS3, awsKinesis, sumologic, all, none)
|
|
56
53
|
*
|
|
57
54
|
* If `LOG_MODE` includes `sumologic` the following environment variables are needed:
|
|
58
55
|
*
|
|
@@ -71,7 +68,8 @@ const SINGLE_MODE = 1;
|
|
|
71
68
|
* | KINESIS_AWS_REGION | Region of the stream
|
|
72
69
|
* | KINESIS_AWS_TIMEOUT | Maximum time before flushing | 1000 | in millisecond
|
|
73
70
|
* | 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
|
|
71
|
+
* | KINESIS_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000
|
|
72
|
+
* | KINESIS_AWS_MAX_RETRIES | Maximum retries to connect to Kinesis | 4
|
|
75
73
|
* | KINESIS_AWS_ACCESS_KEY_ID | Access key id of the stream
|
|
76
74
|
* | KINESIS_AWS_SECRET_ACCESS_KEY | Access key secret of the stream
|
|
77
75
|
* | KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT | Socket timeout for the http handler | 5000 | in millisecond
|
|
@@ -85,7 +83,7 @@ const SINGLE_MODE = 1;
|
|
|
85
83
|
* | S3_AWS_REGION | Region of the bucket
|
|
86
84
|
* | S3_AWS_TIMEOUT | Maximum time before flushing | 5 | in minute
|
|
87
85
|
* | 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
|
|
86
|
+
* | S3_AWS_MAX_EVENTS | Maximum number of accumulated logs before flushing | 1000
|
|
89
87
|
* | S3_AWS_ACCESS_KEY_ID | Access key id of the bucket
|
|
90
88
|
* | S3_AWS_SECRET_ACCESS_KEY | Access key secret of the bucket
|
|
91
89
|
*
|
|
@@ -110,7 +108,7 @@ const checkConfig = (config) => {
|
|
|
110
108
|
};
|
|
111
109
|
|
|
112
110
|
traverseNodeSync(config, 'configuration');
|
|
113
|
-
if (errs.length >
|
|
111
|
+
if (errs.length > 1) {
|
|
114
112
|
throw new Error(`Missing values for ${errs}`);
|
|
115
113
|
}
|
|
116
114
|
};
|
|
@@ -120,9 +118,9 @@ const checkMode = (mode) => {
|
|
|
120
118
|
|
|
121
119
|
if (mode) {
|
|
122
120
|
logMode = split(mode.trim(), /\s*,\s*/u);
|
|
123
|
-
if (logMode.length ===
|
|
124
|
-
if (difference(logMode, ALL_MODES).length !==
|
|
125
|
-
if (logMode.includes(NONE_MODE) && logMode.length !==
|
|
121
|
+
if (logMode.length === 0) throw new Error('Invalid LOG_MODE: cannot be an empty array');
|
|
122
|
+
if (difference(logMode, ALL_MODES).length !== 0) throw new Error(`Invalid items in LOG_MODE: ${mode}`);
|
|
123
|
+
if (logMode.includes(NONE_MODE) && logMode.length !== 1) throw new Error(`Cannot have multiple modes when ${NONE_MODE} is selected`);
|
|
126
124
|
if (logMode.includes(ALL_MODE)) logMode = [SUMOLOGIC, AWS_S3]; // legacy support
|
|
127
125
|
}
|
|
128
126
|
return logMode;
|
|
@@ -161,6 +159,7 @@ if (configuration.mode.includes(AWS_KINESIS)) {
|
|
|
161
159
|
timeout: parseInt(process.env.KINESIS_AWS_TIMEOUT, DECIMAL) || DEFAULT_KINESIS_TIMEOUT, // in millisecond
|
|
162
160
|
maxSize: parseInt(process.env.KINESIS_AWS_MAX_SIZE, DECIMAL) || DEFAULT_KINESIS_MAX_SIZE, // in mByte
|
|
163
161
|
maxEvents: parseInt(process.env.KINESIS_AWS_MAX_EVENTS, DECIMAL) || DEFAULT_KINESIS_MAX_EVENTS,
|
|
162
|
+
maxRetries: parseInt(process.env.KINESIS_AWS_MAX_RETRIES, DECIMAL) || DEFAULT_KINESIS_MAX_RETRIES,
|
|
164
163
|
httpOptions: {
|
|
165
164
|
socketTimeout: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_SOCKET_TIMEOUT, DECIMAL) || DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
|
|
166
165
|
connectionTimeout: parseInt(process.env.KINESIS_AWS_HTTP_OPTIONS_CONNECTION_TIMEOUT, DECIMAL) || DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT,
|
package/eslint.config.js
CHANGED
|
@@ -10,6 +10,8 @@ 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 ALLOWED_CONSTANTS = [0, 1, -1];
|
|
13
15
|
|
|
14
16
|
export default [
|
|
15
17
|
{
|
|
@@ -23,7 +25,7 @@ export default [
|
|
|
23
25
|
processDoc,
|
|
24
26
|
},
|
|
25
27
|
languageOptions: {
|
|
26
|
-
ecmaVersion:
|
|
28
|
+
ecmaVersion: ECMA_VERSION,
|
|
27
29
|
globals: {
|
|
28
30
|
console: 'readonly',
|
|
29
31
|
describe: 'readonly',
|
|
@@ -44,13 +46,14 @@ export default [
|
|
|
44
46
|
'import/no-unresolved': ['error', { amd: true, caseSensitiveStrict: true, commonjs: true }],
|
|
45
47
|
'init-declarations': ['off'],
|
|
46
48
|
'linebreak-style': ['off'],
|
|
47
|
-
'max-len': ['warn', MAX_LENGTH_LINE, { ignoreComments: true }],
|
|
49
|
+
'max-len': ['warn', MAX_LENGTH_LINE, { ignoreComments: true, ignoreRegExpLiterals: true }],
|
|
48
50
|
'max-lines': ['warn', { max: MAX_LINES_IN_FILES, skipComments: true }],
|
|
49
51
|
'max-lines-per-function': ['warn', { max: MAX_LINES_IN_FUNCTION, skipComments: true }],
|
|
50
52
|
'max-params': ['error', MAX_FUNCTION_PARAMETERS],
|
|
51
53
|
'max-statements': ['warn', MAX_STATEMENTS_IN_FUNCTION],
|
|
52
|
-
'no-confusing-arrow': ['off'],
|
|
54
|
+
'no-confusing-arrow': ['off'],
|
|
53
55
|
'no-inline-comments': ['off'],
|
|
56
|
+
'no-magic-numbers': ['error', { ignore: ALLOWED_CONSTANTS, enforceConst: true, detectObjects: true }],
|
|
54
57
|
'no-process-env': ['error'],
|
|
55
58
|
'no-ternary': ['off'],
|
|
56
59
|
'no-undefined': ['off'],
|
package/index.js
CHANGED
|
@@ -94,6 +94,7 @@ if (config.mode.includes(AWS_KINESIS)) {
|
|
|
94
94
|
},
|
|
95
95
|
level: config.level.log,
|
|
96
96
|
maxEvents: config[AWS_KINESIS].maxEvents,
|
|
97
|
+
maxRetries: config[AWS_KINESIS].maxRetries,
|
|
97
98
|
maxSize: config[AWS_KINESIS].maxSize,
|
|
98
99
|
region: config[AWS_KINESIS].region,
|
|
99
100
|
secretAccessKey: config[AWS_KINESIS].secretAccessKey,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
MESSAGE,
|
|
8
8
|
OTHER,
|
|
9
9
|
PARTITION_KEY,
|
|
10
|
+
SYSTEM_ERROR,
|
|
10
11
|
UNKNOWN_ID,
|
|
11
12
|
UNKNOWN_TYPE,
|
|
12
13
|
WARN,
|
|
@@ -27,7 +28,6 @@ import Transport from 'winston-transport';
|
|
|
27
28
|
const RANDOM_MIN = 0;
|
|
28
29
|
const RANDOM_LIMIT = 100;
|
|
29
30
|
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 =
|
|
58
|
+
this.kinesisClientConfig.maxAttempts = options.maxRetries + 1;
|
|
59
59
|
this.kinesisClientConfig.requestHandler = new NodeHttpHandler(
|
|
60
60
|
{
|
|
61
61
|
connectionTimeout: options.httpOptions.connectionTimeout,
|
package/lib/awsS3Transport.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
CLIENTS,
|
|
4
4
|
LOG,
|
|
5
5
|
MESSAGE,
|
|
6
|
+
SYSTEM_ERROR,
|
|
6
7
|
UNKNOWN_ID,
|
|
7
8
|
UNKNOWN_TYPE,
|
|
8
9
|
WARN,
|
|
@@ -21,11 +22,8 @@ import Transport from 'winston-transport';
|
|
|
21
22
|
const events = {};
|
|
22
23
|
const typeEvents = {};
|
|
23
24
|
|
|
24
|
-
const INCR = 1;
|
|
25
|
-
const NONE = 0;
|
|
26
25
|
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() +
|
|
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() +
|
|
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 +=
|
|
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 ===
|
|
121
|
-
if (count ===
|
|
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 ===
|
|
165
|
-
if (count ===
|
|
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
|
@@ -20,6 +20,7 @@ const DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT = 5000; // socket timeout for
|
|
|
20
20
|
const DEFAULT_KINESIS_HTTP_OPTIONS_CONNECTION_TIMEOUT = 5000; // connection timeout for the http handler, in millisecond
|
|
21
21
|
const DEFAULT_KINESIS_MAX_SIZE = 5; // max size of the data before sending to Kinesis, in mByte
|
|
22
22
|
const DEFAULT_KINESIS_MAX_EVENTS = 1000; // max number of events before sending to Kinesis
|
|
23
|
+
const DEFAULT_KINESIS_MAX_RETRIES = 4; // max retries to connect to Kinesis
|
|
23
24
|
const DEFAULT_KINESIS_TIMEOUT = 1000; // max time before sending events to Kinesis, in millisecond
|
|
24
25
|
|
|
25
26
|
const DEFAULT_EXIT_DELAY = 2000; // delay for flushing the transports and exiting, in millisecond
|
|
@@ -43,6 +44,8 @@ const INFO = 'info';
|
|
|
43
44
|
const ERROR = 'error';
|
|
44
45
|
const OTHER = 'other';
|
|
45
46
|
|
|
47
|
+
const SYSTEM_ERROR = 500;
|
|
48
|
+
|
|
46
49
|
export {
|
|
47
50
|
ALL_MODE,
|
|
48
51
|
ALL_MODES,
|
|
@@ -53,6 +56,7 @@ export {
|
|
|
53
56
|
DEFAULT_EXIT_DELAY,
|
|
54
57
|
DEFAULT_FILTER_FILE,
|
|
55
58
|
DEFAULT_KINESIS_MAX_EVENTS,
|
|
59
|
+
DEFAULT_KINESIS_MAX_RETRIES,
|
|
56
60
|
DEFAULT_KINESIS_MAX_SIZE,
|
|
57
61
|
DEFAULT_KINESIS_TIMEOUT,
|
|
58
62
|
DEFAULT_KINESIS_HTTP_OPTIONS_SOCKET_TIMEOUT,
|
|
@@ -77,6 +81,7 @@ export {
|
|
|
77
81
|
PARTITION_KEY,
|
|
78
82
|
SPLAT,
|
|
79
83
|
SUMOLOGIC,
|
|
84
|
+
SYSTEM_ERROR,
|
|
80
85
|
UNKNOWN_TYPE,
|
|
81
86
|
UNKNOWN_ID,
|
|
82
87
|
WARN,
|
|
@@ -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:
|
|
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 +=
|
|
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 =
|
|
22
|
+
res.statusCode = CREATED_RESPONSE;
|
|
23
23
|
res.send(req.body);
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -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 =
|
|
20
|
+
error.statusCode = SYSTEM_ERROR;
|
|
20
21
|
error.title = 'System error';
|
|
21
22
|
|
|
22
23
|
logger.info('this is a test', { user: complexObject }, '12345678');
|
|
@@ -6,7 +6,6 @@ import { getCorrelationId } from '@mimik/request-helper';
|
|
|
6
6
|
import logger from '../index.js';
|
|
7
7
|
|
|
8
8
|
const MAX_ITEMS = 100000;
|
|
9
|
-
const INCR = 1;
|
|
10
9
|
|
|
11
10
|
const complexObject = {
|
|
12
11
|
key: 'property a',
|
|
@@ -28,7 +27,7 @@ const object = {
|
|
|
28
27
|
};
|
|
29
28
|
const objects = [];
|
|
30
29
|
|
|
31
|
-
for (let i = 0; i < MAX_ITEMS; i +=
|
|
30
|
+
for (let i = 0; i < MAX_ITEMS; i += 1) {
|
|
32
31
|
const clonedObject = clone(object);
|
|
33
32
|
|
|
34
33
|
clonedObject.index = i;
|