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

@@ -4,21 +4,17 @@ import (
"errors"
"net/http"
"sync"
"github.com/qdm12/golibs/logging"
)
type handler struct {
logger logging.Logger
healthErr error
healthErrMu sync.RWMutex
}
var errHealthcheckNotRunYet = errors.New("healthcheck did not run yet")
func newHandler(logger logging.Logger) *handler {
func newHandler() *handler {
return &handler{
logger: logger,
healthErr: errHealthcheckNotRunYet,
}
}

View File

@@ -0,0 +1,6 @@
package healthcheck
type Logger interface {
Info(s string)
Error(s string)
}

View File

@@ -5,7 +5,6 @@ import (
"github.com/qdm12/gluetun/internal/configuration"
"github.com/qdm12/gluetun/internal/vpn"
"github.com/qdm12/golibs/logging"
)
var _ ServerRunner = (*Server)(nil)
@@ -15,7 +14,7 @@ type ServerRunner interface {
}
type Server struct {
logger logging.Logger
logger Logger
handler *handler
pinger Pinger
config configuration.Health
@@ -23,10 +22,10 @@ type Server struct {
}
func NewServer(config configuration.Health,
logger logging.Logger, vpnLooper vpn.Looper) *Server {
logger Logger, vpnLooper vpn.Looper) *Server {
return &Server{
logger: logger,
handler: newHandler(logger),
handler: newHandler(),
pinger: newPinger(config.AddressToPing),
config: config,
vpn: vpnHealth{