aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-03-25 03:36:46 +0000
committerGravatar Yong Tang <yong.tang.github@outlook.com> 2019-03-25 11:36:46 +0800
commit45624a0c0a93833bc136f20f316f78dd16462e82 (patch)
treee219b4b0a7fb38223e5bc9f65466fe3b5844ff20 /plugin
parentf08f7e24d6a1ad9d41277e3dcf2d57edb7b9e00f (diff)
downloadcoredns-45624a0c0a93833bc136f20f316f78dd16462e82.tar.gz
coredns-45624a0c0a93833bc136f20f316f78dd16462e82.tar.zst
coredns-45624a0c0a93833bc136f20f316f78dd16462e82.zip
plugin/log: remove ErrorFunc (#2716)
The server handles this case no need to also do it in the log plugin. Means DefaultErrorFunc can be private to the dnsserver and is now renamed to just errorFunc Fixes: #2715 Signed-off-by: Miek Gieben <miek@miek.nl>
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