aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/log/log.go23
-rw-r--r--plugin/log/log_test.go4
-rw-r--r--plugin/log/setup.go2
3 files changed, 5 insertions, 24 deletions
diff --git a/plugin/log/log.go b/plugin/log/log.go
index 2489e03d1..49581dfc4 100644
--- a/plugin/log/log.go
+++ b/plugin/log/log.go
@@ -6,10 +6,8 @@ import (
"time"
"github.com/coredns/coredns/plugin"
- "github.com/coredns/coredns/plugin/metrics/vars"
"github.com/coredns/coredns/plugin/pkg/dnstest"
clog "github.com/coredns/coredns/plugin/pkg/log"
- "github.com/coredns/coredns/plugin/pkg/rcode"
"github.com/coredns/coredns/plugin/pkg/replacer"
"github.com/coredns/coredns/plugin/pkg/response"
"github.com/coredns/coredns/request"
@@ -19,9 +17,8 @@ import (
// Logger is a basic request logging plugin.
type Logger struct {
- Next plugin.Handler
- Rules []Rule
- ErrorFunc func(context.Context, dns.ResponseWriter, *dns.Msg, int) // failover error handler
+ Next plugin.Handler
+ Rules []Rule
repl replacer.Replacer
}
@@ -37,22 +34,6 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
rrw := dnstest.NewRecorder(w)
rc, err := plugin.NextOrFailure(l.Name(), l.Next, ctx, rrw, r)
- if rc > 0 {
- // There was an error up the chain, but no response has been written yet.
- // The error must be handled here so the log entry will record the response size.
- if l.ErrorFunc != nil {
- l.ErrorFunc(ctx, rrw, r, rc)
- } else {
- answer := new(dns.Msg)
- answer.SetRcode(r, rc)
-
- vars.Report(ctx, state, vars.Dropped, rcode.ToString(rc), answer.Len(), time.Now())
-
- w.WriteMsg(answer)
- }
- rc = 0
- }
-
tpe, _ := response.Typify(rrw.Msg, time.Now().UTC())
class := response.Classify(tpe)
// If we don't set up a class in config, the default "all" will be added
diff --git a/plugin/log/log_test.go b/plugin/log/log_test.go
index 97e2b8c71..e7f29fff1 100644
--- a/plugin/log/log_test.go
+++ b/plugin/log/log_test.go
@@ -41,8 +41,8 @@ func TestLoggedStatus(t *testing.T) {
rec := dnstest.NewRecorder(&test.ResponseWriter{})
rcode, _ := logger.ServeDNS(ctx, rec, r)
- if rcode != 0 {
- t.Errorf("Expected rcode to be 0 - was: %d", rcode)
+ if rcode != 2 {
+ t.Errorf("Expected rcode to be 2 - was: %d", rcode)
}
logged := f.String()
diff --git a/plugin/log/setup.go b/plugin/log/setup.go
index 81a2004f2..b9ecb1f72 100644
--- a/plugin/log/setup.go
+++ b/plugin/log/setup.go
@@ -26,7 +26,7 @@ func setup(c *caddy.Controller) error {
}
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
- return Logger{Next: next, Rules: rules, ErrorFunc: dnsserver.DefaultErrorFunc, repl: replacer.New()}
+ return Logger{Next: next, Rules: rules, repl: replacer.New()}
})
return nil