aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-11-06 21:53:10 +0900
committerOphestra <cat@gensokyo.uk>2026-11-06 21:53:10 +0900
commit26610b17d45379e93c9c16d6b0526e0b9d5fdaa4 (patch)
treeace4d57b8e00b2ffa7d018b8bdd5c6ec83189217
parent3a92f0609b69b2ed90b8b38421e9e919db3e3c67 (diff)
internal/report: optionally ignore trivial
Dispatching trivial errors is almost always a waste of resources. These are used for inconsequential, routine events like attempting to load a built-in or already-loaded kernel module. This flag disables them entirely. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/report/report.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/report/report.go b/internal/report/report.go
index 0b0427df..15d6e903 100644
--- a/internal/report/report.go
+++ b/internal/report/report.go
@@ -64,6 +64,9 @@ const (
DNoRecover
// DBypassEarly allows persistent storage to be skipped before it is ready.
DBypassEarly
+ // DIgnoreTrivial makes calling [Reporter.Dispatch] with the [Trivial]
+ // severity a no-op. This should be set in user builds.
+ DIgnoreTrivial
)
// SetFlags sets flags for r.
@@ -142,10 +145,14 @@ func (r *Reporter) getLog() *log.Logger {
// dispatch implements Dispatch but returns the reporting error.
func (r *Reporter) dispatch(severity int, message string, e error) (err error) {
+ flag := r.flag.Load()
+ if flag&DIgnoreTrivial != 0 && severity == Trivial {
+ return
+ }
+
p := Error{severity, message, e}
r.getLog().Println(message+":", e)
- flag := r.flag.Load()
defer func() {
if flag&DNoRecover != 0 && err != nil {
panic(err)