Repository navigation
Share One Log Capture Helper Across Test Classes - #1133
Conversation
Three test classes each carried their own Serilog capturing sink and Log.Logger swap. They now share LogCapture.Capture(). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
A recorded local strict-review pass covers head |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
PR Summary by QodoShare log capture helper across test classes
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link |
There was a problem hiding this comment.
🟡 Changes recommended
The only remaining active item is a nit in PlexCleanerTests/LogCapture.cs: the helper temporarily swaps the global Log.Logger without documenting that callers must stay in the Sequential test collection, so a comment is needed.
1 open issue
What changed in this PR
This PR moves three test classes onto one shared log capture helper. Before, each class had its own Serilog sink and swapped the global Log.Logger around an action. The new LogCapture.Capture(Action) does that swap in one place and returns the captured events. It addresses issue #1129.
Changes:
- Adds
PlexCleanerTests/LogCapture.cs, an internal static helper that captures events atVerboseand restores the original logger infinally. - Removes the per-class sinks and capture helpers from
FfProbeLogTestsandCleanupStepRepeatTests, and switches them to the shared helper. - Moves
ToolFailureLogFormatTestsonto the same helper. It now captures atVerboseinstead of the defaultInformationlevel. Its assertions still pick the sameFailed execution ofevent, so the result does not change.
| File | Description |
|---|---|
| PlexCleanerTests/ToolFailureLogFormatTests.cs | Drops its local sink and inline logger swap, and calls the shared helper. |
| PlexCleanerTests/LogCapture.cs | New shared helper that swaps Log.Logger, captures events, and restores the logger. |
| PlexCleanerTests/FfProbeLogTests.cs | Removes the local sink and Capture helper, and uses the shared helper. |
| PlexCleanerTests/CleanupStepRepeatTests.cs | Removes the local sink and Capture helper, and uses the shared helper. |
Review effort: Lite
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
A recorded local strict-review pass covers head |

Summary
Three test classes each kept their own Serilog capturing sink and swapped the global
Log.Loggeraround an action. This moves them onto one shared helper, as #1129 asks.PlexCleanerTests/LogCapture.cs. A newinternal static classbesideFakeTools.LogCapture.Capture(Action)sendsLog.Loggerto a private capturing sink atVerbose, runs the action, and puts the original logger back and disposes the capture logger infinally. It returns the events asIReadOnlyList<LogEvent>.FfProbeLogTests,CleanupStepRepeatTests,ToolFailureLogFormatTests. Each drops its ownCapturingSink, plus itsCapture()or inline swap, and callsLogCapture.Capture(). All three stay in theSequentialcollection, because the helper still swaps the global logger.Behavior change
None.
ToolFailureLogFormatTestsused to capture at Serilog's defaultInformationlevel and now captures atVerbose. BothLogFailedResultoverloads log only atError, and the test picks its event by theFailed execution oftemplate, so the extra levels don't change what it asserts.Tests
dotnet format style --verify-no-changes --severity=info.Log.Loggerswap. The only otherLog.Logger =in the tests is the global setup inPlexCleanerFixture.Comments label
This PR carries the
commentslabel. It adds one line aboveLogCapture.Capturesaying that it swaps the globalLog.Logger, so every caller joins theSequentialcollection. Copilot asked for that line, and the code can't enforce it.Local Review
A
frontierstrict review ran on this head before the push and raised no findings. It checked the change of capture level, theSequentialcollection's parallel-run setting, the return-type change, and whether any other site should move onto the helper.prose_lint --diffreported nothing. A second pass over 346bd4d, the comment fix, also raised nothing.Closes on promotion: #1129
🤖 Generated with Claude Code