File: level_test.go

package info (click to toggle)
golang-github-apex-log 1.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, bullseye, experimental, forky, sid, trixie
  • size: 316 kB
  • sloc: makefile: 4
file content (27 lines) | stat: -rw-r--r-- 456 bytes parent folder | download | duplicates (2)
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
27
package level_test

import (
	"testing"

	"github.com/stretchr/testify/assert"

	"github.com/apex/log"
	"github.com/apex/log/handlers/level"
	"github.com/apex/log/handlers/memory"
)

func Test(t *testing.T) {
	h := memory.New()

	ctx := log.Logger{
		Handler: level.New(h, log.ErrorLevel),
		Level:   log.InfoLevel,
	}

	ctx.Info("hello")
	ctx.Info("world")
	ctx.Error("boom")

	assert.Len(t, h.Entries, 1)
	assert.Equal(t, h.Entries[0].Message, "boom")
}