@opentermsarchive/engine 0.36.0 → 0.36.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/package.json +1 -1
- package/src/index.js +2 -2
- package/src/logger/index.js +37 -28
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -51,10 +51,10 @@ export default async function track({ services, types, extractOnly, schedule })
|
|
|
51
51
|
await reporter.initialize();
|
|
52
52
|
archivist.attach(reporter);
|
|
53
53
|
} else {
|
|
54
|
-
logger.warn('Configuration key "reporter.githubIssues.repositories.declarations" was not found; the
|
|
54
|
+
logger.warn('Configuration key "reporter.githubIssues.repositories.declarations" was not found; issues on the declarations repository cannot be created');
|
|
55
55
|
}
|
|
56
56
|
} else {
|
|
57
|
-
logger.warn('Environment variable "GITHUB_TOKEN" was not found; the
|
|
57
|
+
logger.warn('Environment variable "GITHUB_TOKEN" was not found; the Reporter module will be ignored');
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (!schedule) {
|
package/src/logger/index.js
CHANGED
|
@@ -34,43 +34,52 @@ const consoleTransport = new winston.transports.Console();
|
|
|
34
34
|
|
|
35
35
|
const transports = [consoleTransport];
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
const logger = winston.createLogger({
|
|
38
|
+
format: alignedWithColorsAndTime,
|
|
39
|
+
transports,
|
|
40
|
+
rejectionHandlers: transports,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (config.get('logger.sendMailOnError')) {
|
|
44
|
+
if (process.env.SMTP_PASSWORD === undefined) {
|
|
45
|
+
logger.warn('Environment variable "SMTP_PASSWORD" was not found; log emails cannot be sent');
|
|
46
|
+
} else {
|
|
47
|
+
const mailerOptions = {
|
|
48
|
+
to: config.get('logger.sendMailOnError.to'),
|
|
49
|
+
from: config.get('logger.sendMailOnError.from'),
|
|
50
|
+
host: config.get('logger.smtp.host'),
|
|
51
|
+
username: config.get('logger.smtp.username'),
|
|
52
|
+
password: process.env.SMTP_PASSWORD,
|
|
53
|
+
ssl: true,
|
|
54
|
+
timeout: 30 * 1000,
|
|
55
|
+
formatter: args => args[Object.getOwnPropertySymbols(args)[1]], // Returns the full error message, the same visible in the console. It is referenced in the argument object with a Symbol of which we do not have the reference but we know it is the second one.
|
|
56
|
+
exitOnError: true,
|
|
57
|
+
};
|
|
58
|
+
|
|
57
59
|
transports.push(new winston.transports.Mail({
|
|
58
60
|
...mailerOptions,
|
|
59
|
-
level: '
|
|
60
|
-
subject: `[OTA]
|
|
61
|
+
level: 'error',
|
|
62
|
+
subject: `[OTA] Error Report — ${os.hostname()}`,
|
|
61
63
|
}));
|
|
64
|
+
|
|
65
|
+
if (config.get('logger.sendMailOnError.sendWarnings')) {
|
|
66
|
+
transports.push(new winston.transports.Mail({
|
|
67
|
+
...mailerOptions,
|
|
68
|
+
level: 'warn',
|
|
69
|
+
subject: `[OTA] Inaccessible content — ${os.hostname()}`,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
logger.configure({
|
|
74
|
+
transports,
|
|
75
|
+
rejectionHandlers: transports,
|
|
76
|
+
});
|
|
62
77
|
}
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
let recordedSnapshotsCount;
|
|
66
81
|
let recordedVersionsCount;
|
|
67
82
|
|
|
68
|
-
const logger = winston.createLogger({
|
|
69
|
-
format: alignedWithColorsAndTime,
|
|
70
|
-
transports,
|
|
71
|
-
rejectionHandlers: transports,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
83
|
logger.onFirstSnapshotRecorded = ({ serviceId, termsType, documentId, id }) => {
|
|
75
84
|
logger.info({ message: `Recorded first snapshot with id ${id}`, serviceId, termsType, documentId });
|
|
76
85
|
recordedSnapshotsCount++;
|