Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions console.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ type ConsoleWriter struct {
// NewConsoleWriter creates and initializes a new ConsoleWriter.
func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter {
w := ConsoleWriter{
Out: os.Stdout,
TimeFormat: consoleDefaultTimeFormat,
PartsOrder: consoleDefaultPartsOrder(),
Out: os.Stdout,
TimeFormat: consoleDefaultTimeFormat,
PartsOrder: consoleDefaultPartsOrder(),
}

for _, opt := range options {
Expand Down
11 changes: 5 additions & 6 deletions ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ type ctxKey struct{}
// replacing it in a new Context), use UpdateContext with the following
// notation:
//
// ctx := r.Context()
// l := zerolog.Ctx(ctx)
// l.UpdateContext(func(c Context) Context {
// return c.Str("bar", "baz")
// })
//
// ctx := r.Context()
// l := zerolog.Ctx(ctx)
// l.UpdateContext(func(c Context) Context {
// return c.Str("bar", "baz")
// })
func (l Logger) WithContext(ctx context.Context) context.Context {
if _, ok := ctx.Value(ctxKey{}).(*Logger); !ok && l.level == Disabled {
// Do not store disabled logger.
Expand Down
8 changes: 4 additions & 4 deletions diode/diode.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ type Writer struct {
//
// Use a diode.Writer when
//
// wr := diode.NewWriter(w, 1000, 0, func(missed int) {
// log.Printf("Dropped %d messages", missed)
// })
// log := zerolog.New(wr)
// wr := diode.NewWriter(w, 1000, 0, func(missed int) {
// log.Printf("Dropped %d messages", missed)
// })
// log := zerolog.New(wr)
//
// If pollInterval is greater than 0, a poller is used otherwise a waiter is
// used.
Expand Down
1 change: 1 addition & 0 deletions diode/diode_example_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !binary_log
// +build !binary_log

package diode_test
Expand Down
1 change: 1 addition & 0 deletions encoder_cbor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build binary_log
// +build binary_log

package zerolog
Expand Down
2 changes: 2 additions & 0 deletions encoder_json.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !binary_log
// +build !binary_log

package zerolog
Expand All @@ -7,6 +8,7 @@ package zerolog

import (
"encoding/base64"

"github.com/rs/zerolog/internal/json"
)

Expand Down
1 change: 1 addition & 0 deletions event_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !binary_log
// +build !binary_log

package zerolog
Expand Down
1 change: 1 addition & 0 deletions go112.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.12
// +build go1.12

package zerolog
Expand Down
1 change: 1 addition & 0 deletions hlog/hlog_example_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !binary_log
// +build !binary_log

package hlog_test
Expand Down
44 changes: 22 additions & 22 deletions internal/cbor/base_test.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package cbor
import (
"bytes"
"encoding/hex"
"testing"
)
func TestAppendKey(t *testing.T) {
want := make([]byte, 0)
want = append(want, 0xbf) // start string
want = append(want, 0x63) // length 3
want = append(want, []byte("key")...)
got := enc.AppendKey([]byte{}, "key")
if !bytes.Equal(got, want) {
t.Errorf("AppendKey(%v)\ngot: 0x%s\nwant: 0x%s",
"key",
hex.EncodeToString(got),
hex.EncodeToString(want))
}
}
package cbor

import (
"bytes"
"encoding/hex"
"testing"
)

func TestAppendKey(t *testing.T) {
want := make([]byte, 0)
want = append(want, 0xbf) // start string
want = append(want, 0x63) // length 3
want = append(want, []byte("key")...)

got := enc.AppendKey([]byte{}, "key")
if !bytes.Equal(got, want) {
t.Errorf("AppendKey(%v)\ngot: 0x%s\nwant: 0x%s",
"key",
hex.EncodeToString(got),
hex.EncodeToString(want))
}
}
1 change: 1 addition & 0 deletions internal/cbor/types_64_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !386
// +build !386

package cbor
Expand Down
60 changes: 30 additions & 30 deletions internal/json/base_test.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package json
import (
"bytes"
"testing"
)
func TestAppendKey(t *testing.T) {
want := make([]byte, 0)
want = append(want, []byte("{\"key\":")...)
got := enc.AppendKey([]byte("{"), "key") // test with empty object
if !bytes.Equal(got, want) {
t.Errorf("AppendKey(%v)\ngot: %s\nwant: %s",
"key",
string(got),
string(want))
}
want = make([]byte, 0)
want = append(want, []byte("},\"key\":")...) // test with non-empty object
got = enc.AppendKey([]byte("}"), "key")
if !bytes.Equal(got, want) {
t.Errorf("AppendKey(%v)\ngot: %s\nwant: %s",
"key",
string(got),
string(want))
}
}
package json

import (
"bytes"
"testing"
)

func TestAppendKey(t *testing.T) {
want := make([]byte, 0)
want = append(want, []byte("{\"key\":")...)

got := enc.AppendKey([]byte("{"), "key") // test with empty object
if !bytes.Equal(got, want) {
t.Errorf("AppendKey(%v)\ngot: %s\nwant: %s",
"key",
string(got),
string(want))
}

want = make([]byte, 0)
want = append(want, []byte("},\"key\":")...) // test with non-empty object

got = enc.AppendKey([]byte("}"), "key")
if !bytes.Equal(got, want) {
t.Errorf("AppendKey(%v)\ngot: %s\nwant: %s",
"key",
string(got),
string(want))
}
}
Loading
Loading