29 lines
754 B
Go
29 lines
754 B
Go
// +build !windows
|
|
|
|
package zerolog
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestMultiSyslogWriter(t *testing.T) {
|
|
sw := &syslogTestWriter{}
|
|
log := New(MultiLevelWriter(SyslogLevelWriter(sw)))
|
|
log.Debug().Msg("debug")
|
|
log.Info().Msg("info")
|
|
log.Warn().Msg("warn")
|
|
log.Error().Msg("error")
|
|
log.Log().Msg("nolevel")
|
|
want := []syslogEvent{
|
|
{"Debug", `{"level":"debug","message":"debug"}` + "\n"},
|
|
{"Info", `{"level":"info","message":"info"}` + "\n"},
|
|
{"Warning", `{"level":"warn","message":"warn"}` + "\n"},
|
|
{"Err", `{"level":"error","message":"error"}` + "\n"},
|
|
{"Info", `{"message":"nolevel"}` + "\n"},
|
|
}
|
|
if got := sw.events; !reflect.DeepEqual(got, want) {
|
|
t.Errorf("Invalid syslog message routing: want %v, got %v", want, got)
|
|
}
|
|
}
|