Improve logging and error handling in logTemporaryDiagnostics

This commit is contained in:
Michael B. Gale
2026-10-22 10:30:34 +01:00
parent c3f2a34e23
commit 26f5c5e4e0
2 changed files with 25 additions and 8 deletions

16
lib/entry-points.js generated
View File

@@ -173085,13 +173085,21 @@ function writeDiagnostic(action, config, language, diagnostic) {
}
function logTemporaryDiagnostics(action) {
const num = temporaryDiagnostics.length;
if (num > 0) {
action.logger.warning(
`${num} diagnostic(s) could not be written to the database and will not appear on the Tool Status Page.`
if (num > 0 && action.logger.isDebug()) {
action.logger.startGroup("Diagnostics in temporary location");
action.logger.debug(
`${num} diagnostic(s) were not moved to the database and remain in the temporary directory.`
);
for (const temporary of temporaryDiagnostics) {
action.logger.debug(fs7.readFileSync(temporary.path, "utf-8"));
try {
action.logger.debug(fs7.readFileSync(temporary.path, "utf-8"));
} catch (err) {
action.logger.debug(
`Failed to read diagnostics from temporary location at '${temporary.path}': ${getErrorMessage(err)}`
);
}
}
action.logger.endGroup();
}
}
function flushDiagnostics(action, config) {

View File

@@ -303,14 +303,23 @@ function writeDiagnostic(
export function logTemporaryDiagnostics(action: ActionState<["Logger"]>) {
const num = temporaryDiagnostics.length;
if (num > 0) {
action.logger.warning(
`${num} diagnostic(s) could not be written to the database and will not appear on the Tool Status Page.`,
if (num > 0 && action.logger.isDebug()) {
action.logger.startGroup("Diagnostics in temporary location");
action.logger.debug(
`${num} diagnostic(s) were not moved to the database and remain in the temporary directory.`,
);
for (const temporary of temporaryDiagnostics) {
action.logger.debug(fs.readFileSync(temporary.path, "utf-8"));
try {
action.logger.debug(fs.readFileSync(temporary.path, "utf-8"));
} catch (err) {
action.logger.debug(
`Failed to read diagnostics from temporary location at '${temporary.path}': ${getErrorMessage(err)}`,
);
}
}
action.logger.endGroup();
}
}