File: level_test.go

package info (click to toggle)
golang-github-bep-logg 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 256 kB
  • sloc: makefile: 9
file content (26 lines) | stat: -rw-r--r-- 587 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package level_test

import (
	"testing"

	qt "github.com/frankban/quicktest"

	"github.com/bep/logg"
	"github.com/bep/logg/handlers/level"
	"github.com/bep/logg/handlers/memory"
)

func TestLevel(t *testing.T) {
	h := memory.New()
	l := logg.New(
		logg.Options{Level: logg.LevelError, Handler: level.New(h, logg.LevelError)},
	)

	info := l.WithLevel(logg.LevelInfo)
	info.Log(logg.String("hello"))
	info.Log(logg.String("world"))
	info.WithLevel(logg.LevelError).Log(logg.String("boom"))

	qt.Assert(t, h.Entries, qt.HasLen, 1)
	qt.Assert(t, "boom", qt.Equals, h.Entries[0].Message)
}