Add GetLevel method (#161)
This commit is contained in:
parent
9938a23cba
commit
60d4b07b61
5
log.go
5
log.go
|
@ -251,6 +251,11 @@ func (l Logger) Level(lvl Level) Logger {
|
|||
return l
|
||||
}
|
||||
|
||||
// GetLevel returns the current Level of l.
|
||||
func (l Logger) GetLevel() Level {
|
||||
return l.level
|
||||
}
|
||||
|
||||
// Sample returns a logger with the s sampler.
|
||||
func (l Logger) Sample(s Sampler) Logger {
|
||||
l.sampler = s
|
||||
|
|
18
log_test.go
18
log_test.go
|
@ -453,6 +453,24 @@ func TestLevel(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestGetLevel(t *testing.T) {
|
||||
levels := []Level{
|
||||
DebugLevel,
|
||||
InfoLevel,
|
||||
WarnLevel,
|
||||
ErrorLevel,
|
||||
FatalLevel,
|
||||
PanicLevel,
|
||||
NoLevel,
|
||||
Disabled,
|
||||
}
|
||||
for _, level := range levels {
|
||||
if got, want := New(nil).Level(level).GetLevel(), level; got != want {
|
||||
t.Errorf("GetLevel() = %v, want: %v", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSampling(t *testing.T) {
|
||||
out := &bytes.Buffer{}
|
||||
log := New(out).Sample(&BasicSampler{N: 2})
|
||||
|
|
Loading…
Reference in New Issue