aboutsummaryrefslogtreecommitdiff
path: root/plugin/file
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/file')
-rw-r--r--plugin/file/file.go12
-rw-r--r--plugin/file/notify.go6
-rw-r--r--plugin/file/reload.go9
-rw-r--r--plugin/file/reload_test.go3
-rw-r--r--plugin/file/secondary.go15
-rw-r--r--plugin/file/secondary_test.go4
-rw-r--r--plugin/file/xfr.go4
7 files changed, 24 insertions, 29 deletions
diff --git a/plugin/file/file.go b/plugin/file/file.go
index ec7857ca5..d6804e124 100644
--- a/plugin/file/file.go
+++ b/plugin/file/file.go
@@ -4,9 +4,9 @@ package file
import (
"fmt"
"io"
- "log"
"github.com/coredns/coredns/plugin"
+ "github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
@@ -52,24 +52,24 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
state.SizeAndDo(m)
w.WriteMsg(m)
- log.Printf("[INFO] Notify from %s for %s: checking transfer", state.IP(), zone)
+ log.Infof("Notify from %s for %s: checking transfer", state.IP(), zone)
ok, err := z.shouldTransfer()
if ok {
z.TransferIn()
} else {
- log.Printf("[INFO] Notify from %s for %s: no serial increase seen", state.IP(), zone)
+ log.Infof("Notify from %s for %s: no serial increase seen", state.IP(), zone)
}
if err != nil {
- log.Printf("[WARNING] Notify from %s for %s: failed primary check: %s", state.IP(), zone, err)
+ log.Warningf("Notify from %s for %s: failed primary check: %s", state.IP(), zone, err)
}
return dns.RcodeSuccess, nil
}
- log.Printf("[INFO] Dropping notify from %s for %s", state.IP(), zone)
+ log.Infof("Dropping notify from %s for %s", state.IP(), zone)
return dns.RcodeSuccess, nil
}
if z.Expired != nil && *z.Expired {
- log.Printf("[ERROR] Zone %s is expired", zone)
+ log.Errorf("Zone %s is expired", zone)
return dns.RcodeServerFailure, nil
}
diff --git a/plugin/file/notify.go b/plugin/file/notify.go
index 1d60d20d5..e7ea0dd78 100644
--- a/plugin/file/notify.go
+++ b/plugin/file/notify.go
@@ -2,9 +2,9 @@ package file
import (
"fmt"
- "log"
"net"
+ "github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/plugin/pkg/rcode"
"github.com/coredns/coredns/request"
@@ -53,9 +53,9 @@ func notify(zone string, to []string) error {
continue
}
if err := notifyAddr(c, m, t); err != nil {
- log.Print("[ERROR] " + err.Error())
+ log.Error(err.Error())
} else {
- log.Printf("[INFO] Sent notify for zone %q to %q", zone, t)
+ log.Infof("Sent notify for zone %q to %q", zone, t)
}
}
return nil
diff --git a/plugin/file/reload.go b/plugin/file/reload.go
index 5effae8eb..28e85b5eb 100644
--- a/plugin/file/reload.go
+++ b/plugin/file/reload.go
@@ -1,9 +1,10 @@
package file
import (
- "log"
"os"
"time"
+
+ "github.com/coredns/coredns/plugin/pkg/log"
)
// TickTime is the default time we use to reload zone. Exported to be tweaked in tests.
@@ -25,7 +26,7 @@ func (z *Zone) Reload() error {
case <-tick.C:
reader, err := os.Open(z.file)
if err != nil {
- log.Printf("[ERROR] Failed to open zone %q in %q: %v", z.origin, z.file, err)
+ log.Errorf("Failed to open zone %q in %q: %v", z.origin, z.file, err)
continue
}
@@ -33,7 +34,7 @@ func (z *Zone) Reload() error {
zone, err := Parse(reader, z.origin, z.file, serial)
if err != nil {
if _, ok := err.(*serialErr); !ok {
- log.Printf("[ERROR] Parsing zone %q: %v", z.origin, err)
+ log.Errorf("Parsing zone %q: %v", z.origin, err)
}
continue
}
@@ -44,7 +45,7 @@ func (z *Zone) Reload() error {
z.Tree = zone.Tree
z.reloadMu.Unlock()
- log.Printf("[INFO] Successfully reloaded zone %q in %q with serial %d", z.origin, z.file, z.Apex.SOA.Serial)
+ log.Infof("Successfully reloaded zone %q in %q with serial %d", z.origin, z.file, z.Apex.SOA.Serial)
z.Notify()
case <-z.reloadShutdown:
diff --git a/plugin/file/reload_test.go b/plugin/file/reload_test.go
index 5185134a2..924889fa5 100644
--- a/plugin/file/reload_test.go
+++ b/plugin/file/reload_test.go
@@ -2,7 +2,6 @@ package file
import (
"io/ioutil"
- "log"
"os"
"strings"
"testing"
@@ -15,8 +14,6 @@ import (
)
func TestZoneReload(t *testing.T) {
- log.SetOutput(ioutil.Discard)
-
fileName, rm, err := test.TempFile(".", reloadZoneTest)
if err != nil {
t.Fatalf("failed to create zone: %s", err)
diff --git a/plugin/file/secondary.go b/plugin/file/secondary.go
index 0d8f70069..5874b62fc 100644
--- a/plugin/file/secondary.go
+++ b/plugin/file/secondary.go
@@ -1,10 +1,11 @@
package file
import (
- "log"
"math/rand"
"time"
+ "github.com/coredns/coredns/plugin/pkg/log"
+
"github.com/miekg/dns"
)
@@ -27,19 +28,19 @@ Transfer:
t := new(dns.Transfer)
c, err := t.In(m, tr)
if err != nil {
- log.Printf("[ERROR] Failed to setup transfer `%s' with `%q': %v", z.origin, tr, err)
+ log.Errorf("Failed to setup transfer `%s' with `%q': %v", z.origin, tr, err)
Err = err
continue Transfer
}
for env := range c {
if env.Error != nil {
- log.Printf("[ERROR] Failed to transfer `%s' from %q: %v", z.origin, tr, env.Error)
+ log.Errorf("Failed to transfer `%s' from %q: %v", z.origin, tr, env.Error)
Err = env.Error
continue Transfer
}
for _, rr := range env.RR {
if err := z1.Insert(rr); err != nil {
- log.Printf("[ERROR] Failed to parse transfer `%s' from: %q: %v", z.origin, tr, err)
+ log.Errorf("Failed to parse transfer `%s' from: %q: %v", z.origin, tr, err)
Err = err
continue Transfer
}
@@ -55,7 +56,7 @@ Transfer:
z.Tree = z1.Tree
z.Apex = z1.Apex
*z.Expired = false
- log.Printf("[INFO] Transferred: %s from %s", z.origin, tr)
+ log.Infof("Transferred: %s from %s", z.origin, tr)
return nil
}
@@ -139,7 +140,7 @@ Restart:
ok, err := z.shouldTransfer()
if err != nil {
- log.Printf("[WARNING] Failed retry check %s", err)
+ log.Warningf("Failed retry check %s", err)
continue
}
@@ -162,7 +163,7 @@ Restart:
ok, err := z.shouldTransfer()
if err != nil {
- log.Printf("[WARNING] Failed refresh check %s", err)
+ log.Warningf("Failed refresh check %s", err)
retryActive = true
continue
}
diff --git a/plugin/file/secondary_test.go b/plugin/file/secondary_test.go
index 8f2c2e15f..6361e3f1c 100644
--- a/plugin/file/secondary_test.go
+++ b/plugin/file/secondary_test.go
@@ -2,8 +2,6 @@ package file
import (
"fmt"
- "io/ioutil"
- "log"
"testing"
"github.com/coredns/coredns/plugin/test"
@@ -72,7 +70,6 @@ const testZone = "secondary.miek.nl."
func TestShouldTransfer(t *testing.T) {
soa := soa{250}
- log.SetOutput(ioutil.Discard)
dns.HandleFunc(testZone, soa.Handler)
defer dns.HandleRemove(testZone)
@@ -117,7 +114,6 @@ func TestShouldTransfer(t *testing.T) {
func TestTransferIn(t *testing.T) {
soa := soa{250}
- log.SetOutput(ioutil.Discard)
dns.HandleFunc(testZone, soa.Handler)
defer dns.HandleRemove(testZone)
diff --git a/plugin/file/xfr.go b/plugin/file/xfr.go
index 4a03779ed..4b74dd1e5 100644
--- a/plugin/file/xfr.go
+++ b/plugin/file/xfr.go
@@ -2,9 +2,9 @@ package file
import (
"fmt"
- "log"
"github.com/coredns/coredns/plugin"
+ "github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
@@ -38,7 +38,7 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in
j, l := 0, 0
records = append(records, records[0]) // add closing SOA to the end
- log.Printf("[INFO] Outgoing transfer of %d records of zone %s to %s started", len(records), x.origin, state.IP())
+ log.Infof("Outgoing transfer of %d records of zone %s to %s started", len(records), x.origin, state.IP())
for i, r := range records {
l += dns.Len(r)
if l > transferLength {