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:
Miek Gieben
2018-04-19 07:41:56 +01:00
committed by GitHub
parent 2095eb7979
commit 26d1432ae6
36 changed files with 101 additions and 132 deletions

View File

@@ -3,13 +3,14 @@ package healthcheck
import (
"io"
"io/ioutil"
"log"
"net"
"net/http"
"net/url"
"sync"
"sync/atomic"
"time"
"github.com/coredns/coredns/plugin/pkg/log"
)
// UpstreamHostDownFunc can be used to customize how Down behaves.
@@ -122,7 +123,7 @@ func (uh *UpstreamHost) HealthCheckURL() {
}()
if err != nil {
log.Printf("[WARNING] Host %s health check probe failed: %v", uh.Name, err)
log.Warningf("Host %s health check probe failed: %v", uh.Name, err)
atomic.AddInt32(&uh.Fails, 1)
return
}
@@ -132,7 +133,7 @@ func (uh *UpstreamHost) HealthCheckURL() {
r.Body.Close()
if r.StatusCode < 200 || r.StatusCode >= 400 {
log.Printf("[WARNING] Host %s health check returned HTTP code %d", uh.Name, r.StatusCode)
log.Warningf("Host %s health check returned HTTP code %d", uh.Name, r.StatusCode)
atomic.AddInt32(&uh.Fails, 1)
return
}

View File

@@ -1,9 +1,10 @@
package healthcheck
import (
"log"
"math/rand"
"sync/atomic"
"github.com/coredns/coredns/plugin/pkg/log"
)
var (
@@ -64,7 +65,7 @@ type Spray struct{}
func (r *Spray) Select(pool HostPool) *UpstreamHost {
rnd := rand.Int() % len(pool)
randHost := pool[rnd]
log.Printf("[WARNING] All hosts reported as down, spraying to target: %s", randHost.Name)
log.Warningf("All hosts reported as down, spraying to target: %s", randHost.Name)
return randHost
}

View File

@@ -1,8 +1,6 @@
package healthcheck
import (
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
"os"
@@ -13,8 +11,6 @@ import (
var workableServer *httptest.Server
func TestMain(m *testing.M) {
log.SetOutput(ioutil.Discard)
workableServer = httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
// do nothing