Unconditionally report unwritten diagnostics at the end of the init Action

This commit is contained in:
Michael B. Gale 2024-04-12 14:00:33 +01:00
parent 3901d1208a
commit 1ac88f37c7
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
6 changed files with 41 additions and 4 deletions

14
lib/diagnostics.js generated
View file

@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.flushDiagnostics = exports.addDiagnostic = exports.makeDiagnostic = void 0;
exports.flushDiagnostics = exports.logUnwrittenDiagnostics = exports.addDiagnostic = exports.makeDiagnostic = void 0;
const fs_1 = require("fs");
const path_1 = __importDefault(require("path"));
const logging_1 = require("./logging");
@ -68,6 +68,18 @@ function writeDiagnostic(config, language, diagnostic) {
logger.warning(`Unable to write diagnostic message to database: ${err}`);
}
}
/** Report if there are unwritten diagnostics and write them to the log. */
function logUnwrittenDiagnostics() {
const logger = (0, logging_1.getActionsLogger)();
const num = unwrittenDiagnostics.length;
if (num > 0) {
logger.warning(`${num} diagnostic(s) could not be written to the database and will not appear on the Tool Status Page.`);
for (const unwritten of unwrittenDiagnostics) {
logger.debug(JSON.stringify(unwritten.diagnostic));
}
}
}
exports.logUnwrittenDiagnostics = logUnwrittenDiagnostics;
/** Writes all unwritten diagnostics to disk. */
function flushDiagnostics(config) {
const logger = (0, logging_1.getActionsLogger)();