traefik/pkg/logs/jaeger_test.go

25 lines
545 B
Go
Raw Normal View History

2022-11-21 17:36:05 +00:00
package logs
import (
2022-11-23 11:14:04 +00:00
"bytes"
2022-11-21 17:36:05 +00:00
"os"
"testing"
"time"
"github.com/rs/zerolog"
2022-11-23 11:14:04 +00:00
"github.com/stretchr/testify/assert"
2022-11-21 17:36:05 +00:00
)
func TestNewJaegerLogger(t *testing.T) {
2022-11-23 11:14:04 +00:00
buf := bytes.NewBuffer(nil)
cwb := zerolog.ConsoleWriter{Out: buf, TimeFormat: time.RFC3339, NoColor: true}
out := zerolog.MultiLevelWriter(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}, cwb)
2022-11-21 17:36:05 +00:00
logger := NewJaegerLogger(zerolog.New(out).With().Caller().Logger())
logger.Infof("foo")
2022-11-23 11:14:04 +00:00
assert.Equal(t, "<nil> DBG jaeger_test.go:21 > foo\n", buf.String())
2022-11-21 17:36:05 +00:00
}