Add a function to retrieve a log level by name (useful for config)

This commit is contained in:
Bruno Carlin 2013-06-25 16:53:42 +02:00
parent 606fd37e7d
commit ac19778676
2 changed files with 25 additions and 0 deletions

15
logging_test.go Normal file
View file

@ -0,0 +1,15 @@
package logging
import "testing"
func Test_LevelByName(t *testing.T) {
for _, levelName := range levelNames {
l, e := LevelByName(levelName)
if e != nil {
t.Errorf("level %s not recognized", levelName)
}
if l.Name() != levelName {
t.Errorf("expected '%s', got '%s'", levelName, l.Name())
}
}
}