Disable logging during unit tests (#5861)

master
Krishna Srinivas 7 years ago committed by Dee Koder
parent b6ca39ea48
commit 11b8e292a7
  1. 10
      cmd/logger/logger.go
  2. 2
      cmd/test-utils_test.go

@ -37,6 +37,9 @@ var (
colorRed = color.New(color.FgRed).SprintfFunc() colorRed = color.New(color.FgRed).SprintfFunc()
) )
// Disable disables all logging, false by default. (used for "go test")
var Disable = false
var trimStrings []string var trimStrings []string
// Level type // Level type
@ -79,6 +82,9 @@ type Console interface {
} }
func consoleLog(console Console, msg string, args ...interface{}) { func consoleLog(console Console, msg string, args ...interface{}) {
if Disable {
return
}
if jsonFlag { if jsonFlag {
console.json(msg, args...) console.json(msg, args...)
} else if quiet { } else if quiet {
@ -221,6 +227,10 @@ func getTrace(traceLevel int) []string {
// LogIf : // LogIf :
func LogIf(ctx context.Context, err error) { func LogIf(ctx context.Context, err error) {
if Disable {
return
}
if err == nil { if err == nil {
return return
} }

@ -75,7 +75,7 @@ func init() {
// Set system resources to maximum. // Set system resources to maximum.
setMaxResources() setMaxResources()
logger.EnableQuiet() logger.Disable = true
} }
// concurreny level for certain parallel tests. // concurreny level for certain parallel tests.

Loading…
Cancel
Save