Add a function to retrieve a log level by name (useful for config)
This commit is contained in:
parent
606fd37e7d
commit
ac19778676
2 changed files with 25 additions and 0 deletions
15
logging_test.go
Normal file
15
logging_test.go
Normal 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())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue