Browse Source

Add debug logging example

Miek Gieben 7 năm trước cách đây
mục cha
commit
15e2168944
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      example.go

+ 4 - 0
example.go

@@ -10,6 +10,7 @@ import (
 
 	"github.com/coredns/coredns/plugin"
 	"github.com/coredns/coredns/plugin/metrics"
+	"github.com/coredns/coredns/plugin/pkg/log"
 
 	"github.com/miekg/dns"
 	"golang.org/x/net/context"
@@ -28,6 +29,9 @@ func (e Example) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
 	// Here we wrap the dns.ResponseWriter in a new ResponseWriter and call the next plugin, when the
 	// answer comes back, it will print "example".
 
+	// Debug log that we've have seen the query. This will only be shown when the debug plugin is loaded.
+	log.Debug("Received response")
+
 	// Wrap.
 	pw := NewResponsePrinter(w)