abra/pkg/web/client.go
decentral1se ef108d63e1
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
refactor: use central logger
2024-07-08 00:01:28 +02:00

26 lines
661 B
Go

package web
import (
"fmt"
"coopcloud.tech/abra/pkg/log"
"github.com/hashicorp/go-retryablehttp"
)
// customLeveledLogger is custom logger with custom logger baked in
type customLeveledLogger struct {
retryablehttp.Logger
}
// Printf wires up our existing custom logger into the custom retryablehttp logger
func (l customLeveledLogger) Printf(msg string, args ...interface{}) {
log.Debugf(fmt.Sprintf(msg, args...))
}
// NewHTTPRetryClient instantiates a new http client with retries baked in
func NewHTTPRetryClient() *retryablehttp.Client {
retryClient := retryablehttp.NewClient()
retryClient.Logger = customLeveledLogger{}
return retryClient
}