use logger

This commit is contained in:
pascal
2026-02-04 23:10:01 +01:00
parent 790ef39187
commit b01809f8e3
5 changed files with 19 additions and 10 deletions

View File

@@ -8,6 +8,8 @@ import (
"strings"
"sync"
log "github.com/sirupsen/logrus"
"github.com/netbirdio/netbird/proxy/internal/roundtrip"
"github.com/netbirdio/netbird/proxy/web"
)
@@ -16,6 +18,7 @@ type ReverseProxy struct {
transport http.RoundTripper
mappingsMux sync.RWMutex
mappings map[string]Mapping
logger *log.Logger
}
// NewReverseProxy configures a new NetBird ReverseProxy.
@@ -24,10 +27,14 @@ type ReverseProxy struct {
// between requested URLs and targets.
// The internal mappings can be modified using the AddMapping
// and RemoveMapping functions.
func NewReverseProxy(transport http.RoundTripper) *ReverseProxy {
func NewReverseProxy(transport http.RoundTripper, logger *log.Logger) *ReverseProxy {
if logger == nil {
logger = log.StandardLogger()
}
return &ReverseProxy{
transport: transport,
mappings: make(map[string]Mapping),
logger: logger,
}
}

View File

@@ -7,8 +7,6 @@ import (
"sort"
"strings"
log "github.com/sirupsen/logrus"
"github.com/netbirdio/netbird/proxy/internal/types"
)
@@ -37,7 +35,7 @@ func (p *ReverseProxy) findTargetForRequest(req *http.Request) (*url.URL, string
host = h
}
log.Debugf("looking for mapping for host: %s, path: %s", host, req.URL.Path)
p.logger.Debugf("looking for mapping for host: %s, path: %s", host, req.URL.Path)
m, exists := p.mappings[host]
if !exists {
return nil, "", "", false