30 lines
776 B
Go
30 lines
776 B
Go
// +build !binary_log
|
|
// +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)
|
|
}
|
|
}
|