Maint: package local narrow Logger interfaces

This commit is contained in:
Quentin McGaw (desktop)
2021-09-23 16:58:21 +00:00
parent d8e008606f
commit cf95692b93
57 changed files with 414 additions and 154 deletions

View File

@@ -0,0 +1,24 @@
package updater
type Logger interface {
infoer
warner
errorer
}
type infoErrorer interface {
infoer
errorer
}
type infoer interface {
Info(s string)
}
type warner interface {
Warn(s string)
}
type errorer interface {
Error(s string)
}

View File

@@ -10,7 +10,6 @@ import (
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/storage"
"github.com/qdm12/golibs/logging"
)
type Looper interface {
@@ -29,7 +28,7 @@ type looper struct {
updater Updater
flusher storage.Flusher
setAllServers func(allServers models.AllServers)
logger logging.Logger
logger infoErrorer
// Internal channels and locks
loopLock sync.Mutex
start chan struct{}
@@ -47,7 +46,7 @@ const defaultBackoffTime = 5 * time.Second
func NewLooper(settings configuration.Updater, currentServers models.AllServers,
flusher storage.Flusher, setAllServers func(allServers models.AllServers),
client *http.Client, logger logging.Logger) Looper {
client *http.Client, logger Logger) Looper {
return &looper{
state: state{
status: constants.Stopped,

View File

@@ -11,7 +11,6 @@ import (
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/updater/resolver"
"github.com/qdm12/gluetun/internal/updater/unzip"
"github.com/qdm12/golibs/logging"
)
type Updater interface {
@@ -26,7 +25,7 @@ type updater struct {
servers models.AllServers
// Functions for tests
logger logging.Logger
logger Logger
timeNow func() time.Time
presolver resolver.Parallel
client *http.Client
@@ -34,7 +33,7 @@ type updater struct {
}
func New(settings configuration.Updater, httpClient *http.Client,
currentServers models.AllServers, logger logging.Logger) Updater {
currentServers models.AllServers, logger Logger) Updater {
if settings.DNSAddress == "" {
settings.DNSAddress = "1.1.1.1"
}