github.com/slackhq/nebula@v1.9.0/test/logger.go (about)

     1  package test
     2  
     3  import (
     4  	"io"
     5  	"os"
     6  
     7  	"github.com/sirupsen/logrus"
     8  )
     9  
    10  func NewLogger() *logrus.Logger {
    11  	l := logrus.New()
    12  
    13  	v := os.Getenv("TEST_LOGS")
    14  	if v == "" {
    15  		l.SetOutput(io.Discard)
    16  		return l
    17  	}
    18  
    19  	switch v {
    20  	case "2":
    21  		l.SetLevel(logrus.DebugLevel)
    22  	case "3":
    23  		l.SetLevel(logrus.TraceLevel)
    24  	default:
    25  		l.SetLevel(logrus.InfoLevel)
    26  	}
    27  
    28  	return l
    29  }