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

@@ -1,11 +1,12 @@
package dnstapio
import (
"log"
"net"
"sync/atomic"
"time"
"github.com/coredns/coredns/plugin/pkg/log"
tap "github.com/dnstap/golang-dnstap"
fs "github.com/farsightsec/golang-framestream"
)
@@ -70,7 +71,7 @@ func (dio *dnstapIO) newConnect() error {
// Connect connects to the dnstop endpoint.
func (dio *dnstapIO) Connect() {
if err := dio.newConnect(); err != nil {
log.Print("[ERROR] No connection to dnstap endpoint")
log.Error("No connection to dnstap endpoint")
}
go dio.serve()
}
@@ -102,16 +103,16 @@ func (dio *dnstapIO) flushBuffer() {
if err := dio.newConnect(); err != nil {
return
}
log.Print("[INFO] Reconnected to dnstap")
log.Info("Reconnected to dnstap")
}
if err := dio.enc.flushBuffer(); err != nil {
log.Printf("[WARN] Connection lost: %s", err)
log.Warningf("Connection lost: %s", err)
dio.closeConnection()
if err := dio.newConnect(); err != nil {
log.Printf("[ERROR] Cannot connect to dnstap: %s", err)
log.Errorf("Cannot connect to dnstap: %s", err)
} else {
log.Print("[INFO] Reconnected to dnstap")
log.Info("Reconnected to dnstap")
}
}
}
@@ -134,7 +135,7 @@ func (dio *dnstapIO) serve() {
dio.write(&payload)
case <-timeout:
if dropped := atomic.SwapUint32(&dio.dropped, 0); dropped > 0 {
log.Printf("[WARN] Dropped dnstap messages: %d", dropped)
log.Warningf("Dropped dnstap messages: %d", dropped)
}
dio.flushBuffer()
timeout = time.After(flushTimeout)