mirror of
https://github.com/coredns/coredns.git
synced 2025-12-09 03:45:11 -05:00
Update all plugins to use plugin/pkg/log (#1694)
* Update all plugins to use plugin/pkg/log I wish this could have been done with sed. Alas manually changed all callers to use the new plugin/pkg/log package. * Error -> Info * Add docs to debug plugin as well
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user