2021-11-10 20:47:38 -07:00
|
|
|
package test
|
2021-03-26 08:46:30 -06:00
|
|
|
|
|
|
|
import (
|
2023-10-31 08:35:13 -06:00
|
|
|
"io"
|
2021-03-26 08:46:30 -06:00
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2021-11-10 20:47:38 -07:00
|
|
|
func NewLogger() *logrus.Logger {
|
2021-03-26 08:46:30 -06:00
|
|
|
l := logrus.New()
|
|
|
|
|
|
|
|
v := os.Getenv("TEST_LOGS")
|
|
|
|
if v == "" {
|
2023-10-31 08:35:13 -06:00
|
|
|
l.SetOutput(io.Discard)
|
2021-03-26 08:46:30 -06:00
|
|
|
return l
|
|
|
|
}
|
|
|
|
|
|
|
|
switch v {
|
|
|
|
case "2":
|
|
|
|
l.SetLevel(logrus.DebugLevel)
|
|
|
|
case "3":
|
|
|
|
l.SetLevel(logrus.TraceLevel)
|
2021-11-03 19:54:04 -06:00
|
|
|
default:
|
|
|
|
l.SetLevel(logrus.InfoLevel)
|
2021-03-26 08:46:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return l
|
|
|
|
}
|