Skip to content

Fix --logwarning log flood and log repair detections as warnings#793

Merged
ptr727 merged 3 commits into
developfrom
feature/log-levels-wrn
Jul 1, 2026
Merged

Fix --logwarning log flood and log repair detections as warnings#793
ptr727 merged 3 commits into
developfrom
feature/log-levels-wrn

Conversation

@ptr727

@ptr727 ptr727 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

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. The Default flag detection had also regressed from a warning to information, so --logwarning no longer surfaced files being modified.

Root cause (proven by instrumentation)

The per-file log elevation was triggered by the SidecarFile.State setter calling PerFileLogLevel.Elevate() on every non-None state change. Since nearly every file gets Verified and/or ClearedDefaultFlags (the new lone-track default logic clears flags on almost every file), nearly every file elevated its session → --logwarning was defeated.

Instrumenting Elevate() produced the smoking gun — the state change fires before the leaked INF:

[WRN] TRACE-ELEVATE-STATE: None -> ClearedDefaultFlags : "f.mkv"   ← elevation
[INF] Reading media info from tools : "f.mkv"                       ← now visible
[INF] MediaInfo : Video ...

It also explains why ClearedDefaultFlags appeared in state with no clearing log: Clearing redundant Default flags is logged at INF before the state is set, so it was suppressed while the state set elevated everything after it.

Fix

  • Revert SidecarFile.State to a plain auto-property — only warning/error events elevate the per-file level, as designed.
  • Detect → warning, cleanup → information. Each repair method now logs a Log.Warning at the point it detects a condition needing action, with rich context, keeping the cleanup steps at information (elevated by the detection warning). Restores the Default flag detection warning (with per-track-type counts) and makes --logwarning surface every modified file. Applied consistently across ~15 repair methods (matching the existing RepairMatroskaStructure shape). Log.Error calls are unchanged.
  • Replace the log-level tests that asserted state-change elevation with a test asserting state changes no longer elevate.

Verification

  • Full suite green (162).
  • --logwarning on a fresh file → WRN detect lines (e.g. Redundant Default flags detected : Video: 1, Audio: 1, Subtitle: 0) + elevated INF cleanup.
  • --logwarning re-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.

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>
Copilot AI review requested due to automatic review settings July 1, 2026 21:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.State mutations by reverting it to an auto-property.
  • Add Log.Warning(...) detection points across multiple processing/repair paths so --logwarning surfaces modified/problem files while keeping cleanup details at Information.
  • 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.

Comment thread PlexCleaner/ProcessFile.cs
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread PlexCleaner/ProcessFile.cs
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@ptr727 ptr727 merged commit 80b3d98 into develop Jul 1, 2026
13 checks passed
@ptr727 ptr727 deleted the feature/log-levels-wrn branch July 1, 2026 21:49
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