@opentermsarchive/engine 2.6.0 → 2.7.0

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.
@@ -48,7 +48,8 @@
48
48
  "host": "smtp-relay.sendinblue.com",
49
49
  "username": "admin@opentermsarchive.org"
50
50
  },
51
- "sendMailOnError": false
51
+ "sendMailOnError": false,
52
+ "timestampPrefix": true
52
53
  },
53
54
  "notifier": {
54
55
  "sendInBlue": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentermsarchive/engine",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Tracks and makes visible changes to the terms of online services",
5
5
  "homepage": "https://opentermsarchive.org",
6
6
  "bugs": {
@@ -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-DD HH:mm:ss' }),
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
- return `${timestamp} ${level.padEnd(15)} ${prefix.padEnd(50)} ${message}`;
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-DD HH:mm:ss' }),
34
- printf(({ level, message, timestamp }) => `${timestamp} ${level.padEnd(15)} ${message}`),
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,
@@ -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-DD HH:mm:ss' }),
11
+ timestamp({ format: 'YYYY-MM-DDTHH:MM:SSZ' }),
12
12
  printf(({ level, message, timestamp, serviceId, termsType, documentId }) => {
13
- let prefix = '';
13
+ const servicePrefix = serviceId && termsType
14
+ ? `${serviceId} — ${termsType}${documentId ? `:${documentId}` : ''}`
15
+ : '';
14
16
 
15
- if (serviceId && termsType) {
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
- if (prefix.length > 75) {
24
- prefix = `${prefix.substring(0, 74)}…`;
25
- }
19
+ const timestampPrefix = config.get('@opentermsarchive/engine.logger.timestampPrefix') ? `${timestamp} ` : '';
26
20
 
27
- return `${timestamp} ${level.padEnd(15)} ${prefix.padEnd(75)} ${message}`;
21
+ return `${timestampPrefix}${level.padEnd(15)} ${truncatedPrefix.padEnd(75)} ${message}`;
28
22
  }),
29
23
  );
30
24