Skip to content

AcceptanceTestSuite: suppress logs per test, only emit on failure#1218

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/add-logging-for-specific-test-failures
Draft

AcceptanceTestSuite: suppress logs per test, only emit on failure#1218
Copilot wants to merge 3 commits intomasterfrom
copilot/add-logging-for-specific-test-failures

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

The AcceptanceTestSuite emits voluminous INFO-level logs for every test case, making CI output noisy and failures harder to diagnose.

Approach

Buffer all java.util.logging output during each individual test and replay it only when that test fails.

Changes

  • CapturingLogHandler (new inner static class) — a JUL Handler that accumulates LogRecords in a synchronized ArrayList; drainRecords() atomically snapshots and clears the buffer.
  • AcceptanceTest.run() — wraps each test execution with log capture:
    • Saves and sets all root-logger handler levels to OFF before the test runs.
    • Installs CapturingLogHandler on the root logger.
    • On failure: restores handler levels and replays the full buffered record set through them.
    • On success: silently discards the buffer.

No new dependencies — uses only java.util.logging APIs.

// Before test: silence existing handlers, start capturing
for (int i = 0; i < existingHandlers.length; i++) {
    originalLevels[i] = existingHandlers[i].getLevel();
    existingHandlers[i].setLevel(Level.OFF);
}
rootLogger.addHandler(capturingHandler);

// ... test runs ...

// In finally: restore, then conditionally replay
for (int i = 0; i < existingHandlers.length; i++) {
    existingHandlers[i].setLevel(originalLevels[i]);
}
if (testFailed) {
    for (LogRecord record : capturingHandler.drainRecords()) {
        for (Handler handler : existingHandlers) {
            handler.publish(record);
        }
    }
}

@chrjohn chrjohn changed the title AcceptanceTestSuite: suppress logs per test, only emit on failure AcceptanceTestSuite: suppress logs per test, only emit on failure May 7, 2026
Comment thread quickfixj-core/src/test/java/quickfix/test/acceptance/AcceptanceTestSuite.java Outdated
Copilot finished work on behalf of chrjohn May 7, 2026 14:41
Copilot AI requested a review from chrjohn May 7, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants