Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 'Interface' usage with correct zerolog api #1069

Merged
merged 2 commits into from
Mar 16, 2022
Merged
Changes from 1 commit
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
38 changes: 26 additions & 12 deletions benchmarks/zerolog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,52 @@ import (
"github.com/rs/zerolog"
)


abhinav marked this conversation as resolved.
Show resolved Hide resolved
func newZerolog() zerolog.Logger {
return zerolog.New(ioutil.Discard).With().Timestamp().Logger()
}


abhinav marked this conversation as resolved.
Show resolved Hide resolved
func newDisabledZerolog() zerolog.Logger {
return newZerolog().Level(zerolog.Disabled)
}

func (u *user) MarshalZerologObject(e *zerolog.Event) {
e.Str("name", u.Name).
Str("email", u.Email).
Int64("createdAt", u.CreatedAt.UnixNano())
}

func (uu users) MarshalZerologArray(a *zerolog.Array) {
for _, u := range uu {
a.Object(u)
}
}

func fakeZerologFields(e *zerolog.Event) *zerolog.Event {
return e.
Int("int", _tenInts[0]).
Interface("ints", _tenInts).
Ints("ints", _tenInts).
Str("string", _tenStrings[0]).
Interface("strings", _tenStrings).
Strs("strings", _tenStrings).
Time("time", _tenTimes[0]).
Interface("times", _tenTimes).
Interface("user1", _oneUser).
Interface("user2", _oneUser).
Interface("users", _tenUsers).
Times("times", _tenTimes).
Object("user1", _oneUser).
Object("user2", _oneUser).
Array("users", _tenUsers).
Err(errExample)
}

func fakeZerologContext(c zerolog.Context) zerolog.Context {
return c.
Int("int", _tenInts[0]).
Interface("ints", _tenInts).
Ints("ints", _tenInts).
Str("string", _tenStrings[0]).
Interface("strings", _tenStrings).
Strs("strings", _tenStrings).
Time("time", _tenTimes[0]).
Interface("times", _tenTimes).
Interface("user1", _oneUser).
Interface("user2", _oneUser).
Interface("users", _tenUsers).
Times("times", _tenTimes).
Object("user1", _oneUser).
Object("user2", _oneUser).
Array("users", _tenUsers).
Err(errExample)
}