fix
This commit is contained in:
parent
f380226321
commit
660e96877b
|
@ -378,7 +378,7 @@ func TestConsoleWriterConfiguration(t *testing.T) {
|
|||
|
||||
t.Run("Sets FormatExtra", func(t *testing.T) {
|
||||
buf := &bytes.Buffer{}
|
||||
w := zerolog.ConsoleWriter{
|
||||
w := zlog.ConsoleWriter{
|
||||
Out: buf, NoColor: true, PartsOrder: []string{"level", "message"},
|
||||
FormatExtra: func(evt map[string]interface{}, buf *bytes.Buffer) error {
|
||||
buf.WriteString("\nAdditional stacktrace")
|
||||
|
@ -406,14 +406,14 @@ func TestConsoleWriterConfiguration(t *testing.T) {
|
|||
expectedOutput := "2022-10-20 20:24:50 INF Foobar\n"
|
||||
evt := `{"time": "2022-10-20 20:24:50", "level": "info", "message": "Foobar"}`
|
||||
|
||||
of := zerolog.TimeFieldFormat
|
||||
of := zlog.TimeFieldFormat
|
||||
defer func() {
|
||||
zerolog.TimeFieldFormat = of
|
||||
zlog.TimeFieldFormat = of
|
||||
}()
|
||||
zerolog.TimeFieldFormat = timeFormat
|
||||
zlog.TimeFieldFormat = timeFormat
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
w := zerolog.ConsoleWriter{Out: buf, NoColor: true, TimeFormat: timeFormat}
|
||||
w := zlog.ConsoleWriter{Out: buf, NoColor: true, TimeFormat: timeFormat}
|
||||
_, err := w.Write([]byte(evt))
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error when writing output: %s", err)
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestNewWriter(t *testing.T) {
|
|||
func TestClose(t *testing.T) {
|
||||
buf := bytes.Buffer{}
|
||||
w := diode.NewWriter(&buf, 1000, 0, func(missed int) {})
|
||||
log := zerolog.New(w)
|
||||
log := zlog.New(w)
|
||||
log.Print("test")
|
||||
w.Close()
|
||||
}
|
||||
|
|
|
@ -126,8 +126,8 @@ func RefererHandler(fieldKey string) func(next http.Handler) http.Handler {
|
|||
func ProtoHandler(fieldKey string) func(next http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
log := zerolog.Ctx(r.Context())
|
||||
log.UpdateContext(func(c zerolog.Context) zerolog.Context {
|
||||
log := zlog.Ctx(r.Context())
|
||||
log.UpdateContext(func(c zlog.Context) zlog.Context {
|
||||
return c.Str(fieldKey, r.Proto)
|
||||
})
|
||||
next.ServeHTTP(w, r)
|
||||
|
|
|
@ -210,7 +210,7 @@ func TestProtoHandler(t *testing.T) {
|
|||
l := FromRequest(r)
|
||||
l.Log().Msg("")
|
||||
}))
|
||||
h = NewHandler(zerolog.New(out))(h)
|
||||
h = NewHandler(zlog.New(out))(h)
|
||||
h.ServeHTTP(nil, r)
|
||||
if want, got := `{"proto":"test"}`+"\n", decodeIfBinary(out); want != got {
|
||||
t.Errorf("Invalid log output, got: %s, want: %s", got, want)
|
||||
|
|
|
@ -102,7 +102,7 @@ func (w journalWriter) Write(p []byte) (n int, err error) {
|
|||
case json.Number:
|
||||
args[jKey] = fmt.Sprint(value)
|
||||
default:
|
||||
b, err := zerolog.InterfaceMarshalFunc(value)
|
||||
b, err := zlog.InterfaceMarshalFunc(value)
|
||||
if err != nil {
|
||||
args[jKey] = fmt.Sprintf("[error: %v]", err)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue