@opentermsarchive/engine 2.6.0 → 2.7.1
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/config/default.json
CHANGED
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import config from 'config';
|
|
1
2
|
import winston from 'winston';
|
|
2
3
|
|
|
3
4
|
import logger from '../../../src/logger/index.js';
|
|
@@ -6,11 +7,13 @@ const { combine, timestamp, printf, colorize } = winston.format;
|
|
|
6
7
|
|
|
7
8
|
logger.format = combine(
|
|
8
9
|
colorize(),
|
|
9
|
-
timestamp({ format: 'YYYY-MM-
|
|
10
|
+
timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }),
|
|
10
11
|
printf(({ level, message, counter, hash, timestamp }) => {
|
|
11
12
|
const prefix = counter && hash ? `${counter.toString().padEnd(6)} ${hash.padEnd(40)}` : '';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
const timestampPrefix = config.get('@opentermsarchive/engine.logger.timestampPrefix') ? `${timestamp} ` : '';
|
|
15
|
+
|
|
16
|
+
return `${timestampPrefix}${level.padEnd(15)} ${prefix.padEnd(50)} ${message}`;
|
|
14
17
|
}),
|
|
15
18
|
);
|
|
16
19
|
|
|
@@ -30,8 +30,12 @@ if (config.get('@opentermsarchive/engine.logger.sendMailOnError')) {
|
|
|
30
30
|
const logger = winston.createLogger({
|
|
31
31
|
format: combine(
|
|
32
32
|
colorize(),
|
|
33
|
-
timestamp({ format: 'YYYY-MM-
|
|
34
|
-
printf(({ level, message, timestamp }) =>
|
|
33
|
+
timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }),
|
|
34
|
+
printf(({ level, message, timestamp }) => {
|
|
35
|
+
const timestampPrefix = config.get('@opentermsarchive/engine.logger.timestampPrefix') ? `${timestamp} ` : '';
|
|
36
|
+
|
|
37
|
+
return `${timestampPrefix}${level.padEnd(15)} ${message}`;
|
|
38
|
+
}),
|
|
35
39
|
),
|
|
36
40
|
transports,
|
|
37
41
|
rejectionHandlers: transports,
|
package/src/logger/index.js
CHANGED
|
@@ -8,23 +8,17 @@ const { combine, timestamp, printf, colorize } = winston.format;
|
|
|
8
8
|
|
|
9
9
|
const alignedWithColorsAndTime = combine(
|
|
10
10
|
colorize(),
|
|
11
|
-
timestamp({ format: 'YYYY-MM-
|
|
11
|
+
timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }),
|
|
12
12
|
printf(({ level, message, timestamp, serviceId, termsType, documentId }) => {
|
|
13
|
-
|
|
13
|
+
const servicePrefix = serviceId && termsType
|
|
14
|
+
? `${serviceId} — ${termsType}${documentId ? `:${documentId}` : ''}`
|
|
15
|
+
: '';
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
prefix = `${serviceId} — ${termsType}`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (documentId) {
|
|
20
|
-
prefix = `${prefix}:${documentId}`;
|
|
21
|
-
}
|
|
17
|
+
const truncatedPrefix = servicePrefix.length > 75 ? `${servicePrefix.slice(0, 74)}…` : servicePrefix;
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
prefix = `${prefix.substring(0, 74)}…`;
|
|
25
|
-
}
|
|
19
|
+
const timestampPrefix = config.get('@opentermsarchive/engine.logger.timestampPrefix') ? `${timestamp} ` : '';
|
|
26
20
|
|
|
27
|
-
return `${
|
|
21
|
+
return `${timestampPrefix}${level.padEnd(15)} ${truncatedPrefix.padEnd(75)} ${message}`;
|
|
28
22
|
}),
|
|
29
23
|
);
|
|
30
24
|
|