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:
Miek Gieben
2018-07-19 16:23:06 +01:00
committed by GitHub
parent c69bed726b
commit f3134da45e
59 changed files with 188 additions and 82 deletions

5
plugin/auto/log_test.go Normal file
View 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
View 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
View 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
View 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
View File

@@ -0,0 +1,5 @@
package debug
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package dnssec
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package dnstapio
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package dnstap
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package erratic
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View 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
View File

@@ -0,0 +1,5 @@
package etcd
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View 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
View File

@@ -0,0 +1,5 @@
package file
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package forward
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View 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
View File

@@ -0,0 +1,5 @@
package hosts
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package kubernetes
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package loadbalance
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -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
View File

@@ -0,0 +1,5 @@
package plugin
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package metadata
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View 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
View File

@@ -0,0 +1,5 @@
package nsid
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package healthcheck
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -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
View 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
View File

@@ -0,0 +1,5 @@
package proxy
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package reload
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View 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
View File

@@ -0,0 +1,5 @@
package root
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package route53
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package secondary
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View 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
View 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
View File

@@ -0,0 +1,5 @@
package trace
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }

View File

@@ -0,0 +1,5 @@
package whoami
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }