mirror of
https://github.com/gophish/gophish
synced 2024-11-15 00:37:14 +00:00
caede2e40b
* Added ParseLevel to set log level (#1671) * Moved logger config into the logger package for better decoupling. Added logging tests. Co-authored-by: Amal Alkhamees <Amalkh5@users.noreply.github.com>
26 lines
591 B
Go
26 lines
591 B
Go
package logger
|
|
|
|
import "testing"
|
|
|
|
import "github.com/sirupsen/logrus"
|
|
|
|
func TestLogLevel(t *testing.T) {
|
|
tests := map[string]logrus.Level{
|
|
"": logrus.InfoLevel,
|
|
"debug": logrus.DebugLevel,
|
|
"info": logrus.InfoLevel,
|
|
"error": logrus.ErrorLevel,
|
|
"fatal": logrus.FatalLevel,
|
|
}
|
|
config := &Config{}
|
|
for level, expected := range tests {
|
|
config.Level = level
|
|
err := Setup(config)
|
|
if err != nil {
|
|
t.Fatalf("error setting logging level %v", err)
|
|
}
|
|
if Logger.Level != expected {
|
|
t.Fatalf("invalid logging level. expected %v got %v", expected, Logger.Level)
|
|
}
|
|
}
|
|
}
|