feat(hooks): reduce log verbosity and improve error reporting in UI (#15297)

This commit is contained in:
Abhi
2025-12-18 19:30:45 -05:00
committed by GitHub
parent 70696e364b
commit 402148dbc4
7 changed files with 84 additions and 17 deletions
+15 -4
View File
@@ -42,6 +42,7 @@ import {
type HookExecutionRequest,
} from '../confirmation-bus/types.js';
import { debugLogger } from '../utils/debugLogger.js';
import { coreEvents } from '../utils/events.js';
/**
* Validates that a value is a non-null object
@@ -573,14 +574,24 @@ export class HookEventHandler {
results: HookExecutionResult[],
aggregated: AggregatedHookResult,
): void {
const successCount = results.filter((r) => r.success).length;
const errorCount = results.length - successCount;
const failedHooks = results.filter((r) => !r.success);
const successCount = results.length - failedHooks.length;
const errorCount = failedHooks.length;
if (errorCount > 0) {
const failedNames = failedHooks
.map((r) => this.getHookNameFromResult(r))
.join(', ');
debugLogger.warn(
`Hook execution for ${eventName}: ${successCount} succeeded, ${errorCount} failed, ` +
`Hook execution for ${eventName}: ${successCount} succeeded, ${errorCount} failed (${failedNames}), ` +
`total duration: ${aggregated.totalDuration}ms`,
);
coreEvents.emitFeedback(
'warning',
`Hook(s) [${failedNames}] failed for event ${eventName}. Press F12 to see the debug drawer for more details.\n`,
);
} else {
debugLogger.debug(
`Hook execution for ${eventName}: ${successCount} hooks executed successfully, ` +
@@ -613,7 +624,7 @@ export class HookEventHandler {
// Log individual errors
for (const error of aggregated.errors) {
debugLogger.error(`Hook execution error: ${error.message}`);
debugLogger.warn(`Hook execution error: ${error.message}`);
}
}