Share unavailable() so the Windows sensor logs unavailable transitions
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package evidence
|
||||
|
||||
import "log"
|
||||
|
||||
// unavailable builds an Unavailable snapshot and logs the reason. It is shared
|
||||
// by every platform sensor so an unobservable window is recorded consistently.
|
||||
func unavailable(reason string) WindowSnapshot {
|
||||
log.Printf("evidence: %s", reason)
|
||||
return WindowSnapshot{Health: EvidenceHealth{Available: false, Reason: reason}}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func (windowsSource) Watch(ctx context.Context, onChange func(WindowSnapshot)) {
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
onChange(WindowSnapshot{Health: EvidenceHealth{Available: false, Reason: "no foreground window"}})
|
||||
onChange(unavailable("no foreground window"))
|
||||
return
|
||||
}
|
||||
onChange(WindowSnapshot{Title: title, Class: class, Health: EvidenceHealth{Available: true}})
|
||||
|
||||
@@ -4,7 +4,6 @@ package evidence
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/jezek/xgb/xproto"
|
||||
"github.com/jezek/xgbutil"
|
||||
@@ -88,7 +87,3 @@ func snapshot(X *xgbutil.XUtil) WindowSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
func unavailable(reason string) WindowSnapshot {
|
||||
log.Printf("evidence: %s", reason)
|
||||
return WindowSnapshot{Health: EvidenceHealth{Available: false, Reason: reason}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user