Log: alert resolver uses state-change logging instead of 1/s
Logs on transition between has-frame and null, and re-logs at most every 10s to avoid spam while idle. No behavior change to the resolve path.
This commit is contained in:
@@ -501,18 +501,22 @@ public partial class MainViewModel : ViewModelBase
|
|||||||
if (element is Source { Type: SourceType.AlertBox } alert)
|
if (element is Source { Type: SourceType.AlertBox } alert)
|
||||||
{
|
{
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
if (now - _lastAlertResolveLog >= TimeSpan.FromSeconds(1))
|
bool hasFrame = frame != null;
|
||||||
|
bool wasLoggedThisState = hasFrame == _lastAlertHadFrame;
|
||||||
|
if (!wasLoggedThisState || now - _lastAlertResolveLog >= TimeSpan.FromSeconds(10))
|
||||||
{
|
{
|
||||||
|
_lastAlertHadFrame = hasFrame;
|
||||||
_lastAlertResolveLog = now;
|
_lastAlertResolveLog = now;
|
||||||
AppLog.Write(frame == null
|
AppLog.Write(hasFrame
|
||||||
? $"Output resolver: alert box '{alert.Id}' frame is null (visible={alert.IsVisible} playing={_alertLayer.IsPlaying}) — skipped in composite"
|
? $"Output resolver: alert box '{alert.Id}' frame {frame!.Width}x{frame!.Height} (visible={alert.IsVisible} playing={_alertLayer.IsPlaying})"
|
||||||
: $"Output resolver: alert box '{alert.Id}' frame {frame!.Width}x{frame!.Height} (visible={alert.IsVisible} playing={_alertLayer.IsPlaying})");
|
: $"Output resolver: alert box '{alert.Id}' frame is null (visible={alert.IsVisible} playing={_alertLayer.IsPlaying}) — skipped in composite");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTime _lastAlertResolveLog = DateTime.MinValue;
|
private DateTime _lastAlertResolveLog = DateTime.MinValue;
|
||||||
|
private bool _lastAlertHadFrame = false;
|
||||||
|
|
||||||
private DateTime _lastWebcamNullLog = DateTime.MinValue;
|
private DateTime _lastWebcamNullLog = DateTime.MinValue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user