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

@@ -5,11 +5,9 @@ import (
"net/http"
"sync"
"time"
"github.com/qdm12/golibs/logging"
)
func newHandler(ctx context.Context, wg *sync.WaitGroup, logger logging.Logger,
func newHandler(ctx context.Context, wg *sync.WaitGroup, logger Logger,
stealth, verbose bool, username, password string) http.Handler {
const httpTimeout = 24 * time.Hour
return &handler{
@@ -30,7 +28,7 @@ type handler struct {
ctx context.Context
wg *sync.WaitGroup
client *http.Client
logger logging.Logger
logger Logger
verbose, stealth bool
username, password string
}

View File

@@ -0,0 +1,21 @@
package httpproxy
type Logger interface {
Debug(s string)
infoer
Warn(s string)
errorer
}
type infoErrorer interface {
infoer
errorer
}
type infoer interface {
Info(s string)
}
type errorer interface {
Error(s string)
}

View File

@@ -10,7 +10,6 @@ import (
"github.com/qdm12/gluetun/internal/httpproxy/state"
"github.com/qdm12/gluetun/internal/loopstate"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/golibs/logging"
)
var _ Looper = (*Loop)(nil)
@@ -26,7 +25,7 @@ type Loop struct {
statusManager loopstate.Manager
state state.Manager
// Other objects
logger logging.Logger
logger Logger
// Internal channels and locks
running chan models.LoopStatus
stop, stopped chan struct{}
@@ -37,7 +36,7 @@ type Loop struct {
const defaultBackoffTime = 10 * time.Second
func NewLoop(logger logging.Logger, settings configuration.HTTPProxy) *Loop {
func NewLoop(logger Logger, settings configuration.HTTPProxy) *Loop {
start := make(chan struct{})
running := make(chan models.LoopStatus)
stop := make(chan struct{})

View File

@@ -5,18 +5,16 @@ import (
"net/http"
"sync"
"time"
"github.com/qdm12/golibs/logging"
)
type Server struct {
address string
handler http.Handler
logger logging.Logger
logger infoErrorer
internalWG *sync.WaitGroup
}
func New(ctx context.Context, address string, logger logging.Logger,
func New(ctx context.Context, address string, logger Logger,
stealth, verbose bool, username, password string) *Server {
wg := &sync.WaitGroup{}
return &Server{