Fix --logwarning log flood and log repair detections as warnings#793
Merged
Conversation
The per-file log elevation was triggered by the SidecarFile.State setter calling PerFileLogLevel.Elevate() on every non-None state change. Because nearly every file gets Verified or ClearedDefaultFlags, nearly every file elevated, so --logwarning showed full information output for all files instead of only files with a warning or error. Confirmed by instrumenting Elevate() and observing the state-change trigger fire before the leaked information events. - Revert SidecarFile.State to a plain auto-property; only warning/error events elevate the per-file log level, as intended. - Log a warning at the point each repair method detects a condition needing action (redundant Default flags with per-type counts, invalid language tags, interlaced video, tracks needing re-encode, etc.), keeping the cleanup steps at information level (elevated by the detection warning). This restores the "Multiple Default flagged tracks" style detection warning that regressed to information, and makes --logwarning surface every modified file. - Replace the log-level tests that asserted state-change elevation with a test asserting state changes no longer elevate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts PlexCleaner's per-file logging behavior so --logwarning no longer gets flooded by information-level output, while still surfacing files that require repair/cleanup by emitting explicit detection warnings that elevate per-file logging for subsequent cleanup steps.
Changes:
- Remove per-file log elevation from
SidecarFile.Statemutations by reverting it to an auto-property. - Add
Log.Warning(...)detection points across multiple processing/repair paths so--logwarningsurfaces modified/problem files while keeping cleanup details atInformation. - Update per-file log level tests to assert state changes no longer elevate logging.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| PlexCleaner/ProcessFile.cs | Adds warning-level “detected” logs ahead of repair/cleanup actions to drive per-file elevation under --logwarning. |
| PlexCleaner/SidecarFile.cs | Removes state-setter side effects (log elevation) by making State a plain auto-property. |
| PlexCleanerTests/PerFileLogLevelTests.cs | Updates tests to match the new “state does not elevate” contract. |
| HISTORY.md | Documents the logging behavior change for v3.20 release notes. |
GetTrackList allocates and sorts a combined list; count the SetFlags tracks directly from the per-type collections in the detection warning. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RepairMetadataRemux computed HasMetadataErrors for Remove/ReMux/SetLanguage in the early-exit and again in the detection warning. Evaluate each once into locals and reuse them, avoiding the duplicate GetTrackList allocations. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Under
--logwarning, the log was flooded with information-level output for files that had no warning or error — a real run showed 2869 of 2899 files emitting full INF with zero WRN/ERR. TheDefaultflag detection had also regressed from a warning to information, so--logwarningno longer surfaced files being modified.Root cause (proven by instrumentation)
The per-file log elevation was triggered by the
SidecarFile.Statesetter callingPerFileLogLevel.Elevate()on every non-Nonestate change. Since nearly every file getsVerifiedand/orClearedDefaultFlags(the new lone-track default logic clears flags on almost every file), nearly every file elevated its session →--logwarningwas defeated.Instrumenting
Elevate()produced the smoking gun — the state change fires before the leaked INF:It also explains why
ClearedDefaultFlagsappeared in state with no clearing log:Clearing redundant Default flagsis logged at INF before the state is set, so it was suppressed while the state set elevated everything after it.Fix
SidecarFile.Stateto a plain auto-property — only warning/error events elevate the per-file level, as designed.Log.Warningat the point it detects a condition needing action, with rich context, keeping the cleanup steps at information (elevated by the detection warning). Restores theDefaultflag detection warning (with per-track-type counts) and makes--logwarningsurface every modified file. Applied consistently across ~15 repair methods (matching the existingRepairMatroskaStructureshape).Log.Errorcalls are unchanged.Verification
--logwarningon a fresh file → WRN detect lines (e.g.Redundant Default flags detected : Video: 1, Audio: 1, Subtitle: 0) + elevated INF cleanup.--logwarningre-run on the now-clean file → zero per-file INF/WRN (only the always-on banner/summary).Fixes an unreleased 3.20 regression; no version bump.