diff options
Diffstat (limited to 'plugin/proxy')
-rw-r--r-- | plugin/proxy/google.go | 18 | ||||
-rw-r--r-- | plugin/proxy/grpc.go | 8 | ||||
-rw-r--r-- | plugin/proxy/healthcheck_test.go | 6 |
3 files changed, 13 insertions, 19 deletions
diff --git a/plugin/proxy/google.go b/plugin/proxy/google.go index 0fa1356e1..9192ce83b 100644 --- a/plugin/proxy/google.go +++ b/plugin/proxy/google.go @@ -5,13 +5,13 @@ import ( "encoding/json" "fmt" "io/ioutil" - "log" "net" "net/http" "net/url" "time" "github.com/coredns/coredns/plugin/pkg/healthcheck" + "github.com/coredns/coredns/plugin/pkg/log" "github.com/coredns/coredns/request" "github.com/miekg/dns" @@ -65,7 +65,7 @@ func (g *google) Exchange(ctx context.Context, addr string, state request.Reques return m, nil } - log.Printf("[WARNING] Failed to connect to HTTPS backend %q: %s", g.endpoint, backendErr) + log.Warningf("Failed to connect to HTTPS backend %q: %s", g.endpoint, backendErr) return nil, backendErr } @@ -119,17 +119,17 @@ func (g *google) OnStartup(p *Proxy) error { new, err := g.bootstrapProxy.Lookup(state, g.endpoint, dns.TypeA) if err != nil { - log.Printf("[WARNING] Failed to bootstrap A records %q: %s", g.endpoint, err) + log.Warningf("Failed to bootstrap A records %q: %s", g.endpoint, err) } else { addrs, err1 := extractAnswer(new) if err1 != nil { - log.Printf("[WARNING] Failed to bootstrap A records %q: %s", g.endpoint, err1) + log.Warningf("Failed to bootstrap A records %q: %s", g.endpoint, err1) } else { up := newUpstream(addrs, oldUpstream.(*staticUpstream)) p.Upstreams = &[]Upstream{up} - log.Printf("[INFO] Bootstrapping A records %q found: %v", g.endpoint, addrs) + log.Infof("Bootstrapping A records %q found: %v", g.endpoint, addrs) } } @@ -140,24 +140,24 @@ func (g *google) OnStartup(p *Proxy) error { select { case <-tick.C: - log.Printf("[INFO] Resolving A records %q", g.endpoint) + log.Infof("Resolving A records %q", g.endpoint) new, err := g.bootstrapProxy.Lookup(state, g.endpoint, dns.TypeA) if err != nil { - log.Printf("[WARNING] Failed to resolve A records %q: %s", g.endpoint, err) + log.Warningf("Failed to resolve A records %q: %s", g.endpoint, err) continue } addrs, err1 := extractAnswer(new) if err1 != nil { - log.Printf("[WARNING] Failed to resolve A records %q: %s", g.endpoint, err1) + log.Warningf("Failed to resolve A records %q: %s", g.endpoint, err1) continue } up := newUpstream(addrs, oldUpstream.(*staticUpstream)) p.Upstreams = &[]Upstream{up} - log.Printf("[INFO] Resolving A records %q found: %v", g.endpoint, addrs) + log.Infof("Resolving A records %q found: %v", g.endpoint, addrs) case <-g.quit: return diff --git a/plugin/proxy/grpc.go b/plugin/proxy/grpc.go index 2844a1c71..334cd5264 100644 --- a/plugin/proxy/grpc.go +++ b/plugin/proxy/grpc.go @@ -3,9 +3,9 @@ package proxy import ( "crypto/tls" "fmt" - "log" "github.com/coredns/coredns/pb" + "github.com/coredns/coredns/plugin/pkg/log" "github.com/coredns/coredns/plugin/pkg/trace" "github.com/coredns/coredns/request" @@ -67,7 +67,7 @@ func (g *grpcClient) OnShutdown(p *Proxy) error { for i, conn := range g.conns { err := conn.Close() if err != nil { - log.Printf("[WARNING] Error closing connection %d: %s\n", i, err) + log.Warningf("Error closing connection %d: %s\n", i, err) } } g.conns = []*grpc.ClientConn{} @@ -84,13 +84,13 @@ func (g *grpcClient) OnStartup(p *Proxy) error { intercept := otgrpc.OpenTracingClientInterceptor(t.Tracer(), otgrpc.IncludingSpans(onlyIfParent)) dialOpts = append(dialOpts, grpc.WithUnaryInterceptor(intercept)) } else { - log.Printf("[WARNING] Wrong type for trace plugin reference: %s", p.Trace) + log.Warningf("Wrong type for trace plugin reference: %s", p.Trace) } } for _, host := range g.upstream.Hosts { conn, err := grpc.Dial(host.Name, dialOpts...) if err != nil { - log.Printf("[WARNING] Skipping gRPC host '%s' due to Dial error: %s\n", host.Name, err) + log.Warningf("Skipping gRPC host '%s' due to Dial error: %s\n", host.Name, err) } else { g.clients[host.Name] = pb.NewDnsServiceClient(conn) g.conns = append(g.conns, conn) diff --git a/plugin/proxy/healthcheck_test.go b/plugin/proxy/healthcheck_test.go index 53b9446ff..67f5d0f2d 100644 --- a/plugin/proxy/healthcheck_test.go +++ b/plugin/proxy/healthcheck_test.go @@ -2,8 +2,6 @@ package proxy import ( "fmt" - "io/ioutil" - "log" "net/http" "net/http/httptest" "strings" @@ -18,10 +16,6 @@ import ( "github.com/miekg/dns" ) -func init() { - log.SetOutput(ioutil.Discard) -} - func TestUnhealthy(t *testing.T) { // High HC interval, we want to test the HC after failed queries. config := "proxy . %s {\n health_check /healthcheck:%s 10s \nfail_timeout 100ms\n}" |