mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
Clean up tests logging (#1979)
* Clean up tests logging This cleans up the travis logs so you can see the failures better. Older tests in tests/ would call log.SetOutput(ioutil.Discard) in a haphazard way. This add log.Discard and put an `init` function in each package's dir (no way to do this globally). The cleanup in tests/ is clear. All plugins also got this init function to have some uniformity and kill any (future) logging there in the tests as well. There is a one-off in pkg/healthcheck because that does log. Signed-off-by: Miek Gieben <miek@miek.nl> * bring back original log_test.go Signed-off-by: Miek Gieben <miek@miek.nl> * suppress logging here as well Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
5
plugin/auto/log_test.go
Normal file
5
plugin/auto/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package auto
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/bind/log_test.go
Normal file
5
plugin/bind/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package bind
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/cache/log_test.go
vendored
Normal file
5
plugin/cache/log_test.go
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
package cache
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/chaos/log_test.go
Normal file
5
plugin/chaos/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package chaos
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/debug/log_test.go
Normal file
5
plugin/debug/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package debug
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/dnssec/log_test.go
Normal file
5
plugin/dnssec/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package dnssec
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/dnstap/dnstapio/log_test.go
Normal file
5
plugin/dnstap/dnstapio/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package dnstapio
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/dnstap/log_test.go
Normal file
5
plugin/dnstap/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package dnstap
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/erratic/log_test.go
Normal file
5
plugin/erratic/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package erratic
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/errors/log_test.go
Normal file
5
plugin/errors/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package errors
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/etcd/log_test.go
Normal file
5
plugin/etcd/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package etcd
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/federation/log_test.go
Normal file
5
plugin/federation/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package federation
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/file/log_test.go
Normal file
5
plugin/file/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package file
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/forward/log_test.go
Normal file
5
plugin/forward/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package forward
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/health/log_test.go
Normal file
5
plugin/health/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package health
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/hosts/log_test.go
Normal file
5
plugin/hosts/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package hosts
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/kubernetes/log_test.go
Normal file
5
plugin/kubernetes/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package kubernetes
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/loadbalance/log_test.go
Normal file
5
plugin/loadbalance/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package loadbalance
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
@@ -8,12 +8,15 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/coredns/plugin/pkg/dnstest"
|
||||
clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
"github.com/coredns/coredns/plugin/pkg/response"
|
||||
"github.com/coredns/coredns/plugin/test"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
func init() { clog.Discard() }
|
||||
|
||||
func TestLoggedStatus(t *testing.T) {
|
||||
var f bytes.Buffer
|
||||
rule := Rule{
|
||||
|
||||
5
plugin/log_test.go
Normal file
5
plugin/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package plugin
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/metadata/log_test.go
Normal file
5
plugin/metadata/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package metadata
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/metrics/log_test.go
Normal file
5
plugin/metrics/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package metrics
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/nsid/log_test.go
Normal file
5
plugin/nsid/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package nsid
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/pkg/healthcheck/log_test.go
Normal file
5
plugin/pkg/healthcheck/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package healthcheck
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
@@ -10,6 +10,7 @@ package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
golog "log"
|
||||
)
|
||||
|
||||
@@ -61,6 +62,9 @@ func Error(v ...interface{}) { log(err, v...) }
|
||||
// Errorf is equivalent to log.Printf, but prefixed with "[ERROR] ".
|
||||
func Errorf(format string, v ...interface{}) { logf(err, format, v...) }
|
||||
|
||||
// Discard sets the log output to /dev/null.
|
||||
func Discard() { golog.SetOutput(ioutil.Discard) }
|
||||
|
||||
const (
|
||||
debug = "[DEBUG] "
|
||||
err = "[ERROR] "
|
||||
|
||||
5
plugin/pprof/log_test.go
Normal file
5
plugin/pprof/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package pprof
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/proxy/log_test.go
Normal file
5
plugin/proxy/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package proxy
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/reload/log_test.go
Normal file
5
plugin/reload/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package reload
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/rewrite/log_test.go
Normal file
5
plugin/rewrite/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package rewrite
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/root/log_test.go
Normal file
5
plugin/root/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package root
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/route53/log_test.go
Normal file
5
plugin/route53/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package route53
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/secondary/log_test.go
Normal file
5
plugin/secondary/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package secondary
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/template/log_test.go
Normal file
5
plugin/template/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package template
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/tls/log_test.go
Normal file
5
plugin/tls/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package tls
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/trace/log_test.go
Normal file
5
plugin/trace/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package trace
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
5
plugin/whoami/log_test.go
Normal file
5
plugin/whoami/log_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package whoami
|
||||
|
||||
import clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
func init() { clog.Discard() }
|
||||
Reference in New Issue
Block a user