2021-11-04 02:54:04 +01:00
|
|
|
package util
|
2021-03-26 15:46:30 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewTestLogger() *logrus.Logger {
|
|
|
|
l := logrus.New()
|
|
|
|
|
|
|
|
v := os.Getenv("TEST_LOGS")
|
|
|
|
if v == "" {
|
|
|
|
l.SetOutput(ioutil.Discard)
|
|
|
|
return l
|
|
|
|
}
|
|
|
|
|
|
|
|
switch v {
|
|
|
|
case "2":
|
|
|
|
l.SetLevel(logrus.DebugLevel)
|
|
|
|
case "3":
|
|
|
|
l.SetLevel(logrus.TraceLevel)
|
2021-11-04 02:54:04 +01:00
|
|
|
default:
|
|
|
|
l.SetLevel(logrus.InfoLevel)
|
2021-03-26 15:46:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return l
|
|
|
|
}
|