diff --git a/fleetd/src/test/java/dev/ltms/fleet/testing/CapturedLog.java b/fleetd/src/test/java/dev/ltms/fleet/testing/CapturedLog.java index 9980b73..e445f7f 100644 --- a/fleetd/src/test/java/dev/ltms/fleet/testing/CapturedLog.java +++ b/fleetd/src/test/java/dev/ltms/fleet/testing/CapturedLog.java @@ -21,9 +21,29 @@ import java.util.List; * fork. try-with-resources makes "restored the appender but not the level" impossible to write, * because there is only one thing to close. * - *

This is the one way to pin or capture a logger's level and output in this test tree — do not - * hand-roll the {@code ListAppender} + {@code setLevel} + {@code finally detachAppender} pattern; - * use {@link #at} or {@link #of} instead. + *

New code must use this rather than hand-rolling the {@code ListAppender} + {@code setLevel} + + * {@code finally detachAppender} pattern: use {@link #at} or {@link #of}. It is not yet + * the only instance of the pattern in this test tree, and the earlier wording here said it was — + * which would leave a reader who greps unable to tell a leftover from a violation. + * + *

Measured on main at af95897 (2026-09-12): nine test files still hand-roll it, with 42 + * {@code setLevel} calls on a raw logback {@code Logger} between them — {@code + * FleetdStartupReportTest}, {@code GitHostShapeReportTest}, {@code MemberCredentialsGapReportTest}, + * {@code MemberTrustModelReportTest}, {@code FleetHealthMonitorTest}, {@code + * ClaudeCodeLauncherTest}, {@code HerdrPeerLauncherAllowListWiringTest}, {@code + * HerdrPeerLauncherCharterTest} and {@code OpenCodeLauncherTest}. Every one of them pairs its pin + * with a restore, so none is the fleetd #525 leak and none was in fleetd #529's scope, which was + * the 19 unrestored pins only. They are unmigrated, not broken. + * + *

Re-measure with the two commands below, from the repo root. A file that appears in the first + * list and not the second still hand-rolls the pattern. When the first list comes back empty, this + * paragraph is spent and the sentence above can go back to saying "the one way" — delete the + * paragraph then rather than updating the count. + * + *

{@code
+ * grep -rlE '\.setLevel\(' fleetd/src/test/java --include='*.java' | grep -v CapturedLog.java
+ * grep -rl 'CapturedLog' fleetd/src/test/java --include='*.java'
+ * }
*/ public final class CapturedLog implements AutoCloseable { private final Logger logger;