lib: Consistently set suture logging (#7202)

This commit is contained in:
Simon Frei
2020-12-18 19:44:00 +01:00
committed by GitHub
parent 7919310dc6
commit fa40ccece1
10 changed files with 21 additions and 26 deletions
+11 -1
View File
@@ -16,6 +16,7 @@ import (
"strings"
"time"
"github.com/syncthing/syncthing/lib/logger"
"github.com/syncthing/syncthing/lib/sync"
"github.com/thejerf/suture/v4"
@@ -390,8 +391,17 @@ func OnSupervisorDone(sup *suture.Supervisor, fn func()) {
sup.Add(&doneService{fn})
}
func Spec() suture.Spec {
func SpecWithDebugLogger(l logger.Logger) suture.Spec {
return spec(func(e suture.Event) { l.Debugln(e) })
}
func SpecWithInfoLogger(l logger.Logger) suture.Spec {
return spec(func(e suture.Event) { l.Infoln(e) })
}
func spec(eventHook suture.EventHook) suture.Spec {
return suture.Spec{
EventHook: eventHook,
PassThroughPanics: true,
DontPropagateTermination: false,
}