Skip to content

Commit

Permalink
docs: Fix object example in readme (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
thessem authored Aug 24, 2024
1 parent b61d35b commit 44b8f84
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,28 +143,28 @@ Log a message and 10 fields:

| Package | Time | Time % to zap | Objects Allocated |
| :------ | :--: | :-----------: | :---------------: |
| :zap: zap | 570 ns/op | +0% | 5 allocs/op
| :zap: zap (sugared) | 861 ns/op | +51% | 10 allocs/op
| :zap: :nail_care: zap-prettyconsole | 2050 ns/op | +260% | 11 allocs/op
| :zap: :nail_care: zap-prettyconsole (sugared) | 2484 ns/op | +336% | 16 allocs/op
| :zap: zap | 562 ns/op | +0% | 5 allocs/op
| :zap: zap (sugared) | 877 ns/op | +56% | 10 allocs/op
| :zap: :nail_care: zap-prettyconsole | 1948 ns/op | +247% | 11 allocs/op
| :zap: :nail_care: zap-prettyconsole (sugared) | 2441 ns/op | +334% | 16 allocs/op

Log a message with a logger that already has 10 fields of context:

| Package | Time | Time % to zap | Objects Allocated |
| :------ | :--: | :-----------: | :---------------: |
| :zap: zap | 57 ns/op | +0% | 0 allocs/op
| :zap: zap (sugared) | 67 ns/op | +18% | 1 allocs/op
| :zap: :nail_care: zap-prettyconsole | 1705 ns/op | +2891% | 6 allocs/op
| :zap: :nail_care: zap-prettyconsole (sugared) | 1712 ns/op | +2904% | 7 allocs/op
| :zap: zap | 48 ns/op | +0% | 0 allocs/op
| :zap: zap (sugared) | 66 ns/op | +38% | 1 allocs/op
| :zap: :nail_care: zap-prettyconsole | 1627 ns/op | +3290% | 6 allocs/op
| :zap: :nail_care: zap-prettyconsole (sugared) | 1646 ns/op | +3329% | 7 allocs/op

Log a static string, without any context or `printf`-style templating:

| Package | Time | Time % to zap | Objects Allocated |
| :------ | :--: | :-----------: | :---------------: |
| :zap: :nail_care: zap-prettyconsole | 39 ns/op | -11% | 0 allocs/op
| :zap: zap | 44 ns/op | +0% | 0 allocs/op
| :zap: zap (sugared) | 60 ns/op | +36% | 1 allocs/op
| :zap: :nail_care: zap-prettyconsole (sugared) | 62 ns/op | +41% | 1 allocs/op
| :zap: zap | 51 ns/op | +0% | 0 allocs/op
| :zap: :nail_care: zap-prettyconsole | 54 ns/op | +6% | 0 allocs/op
| :zap: zap (sugared) | 62 ns/op | +22% | 1 allocs/op
| :zap: :nail_care: zap-prettyconsole (sugared) | 62 ns/op | +22% | 1 allocs/op

Released under the [MIT License](LICENSE.txt)

Expand Down
6 changes: 3 additions & 3 deletions internal/readme/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ type UserAddress struct {
func (u *User) MarshalLogObject(e zapcore.ObjectEncoder) error {
e.AddString("name", u.Name)
e.AddInt("age", u.Age)
e.OpenNamespace("address")
e.AddString("street", u.Address.Street)
e.AddString("city", u.Address.City)
if u.Friend != nil {
_ = e.AddObject("friend", u.Friend)
}
e.OpenNamespace("address")
e.AddString("street", u.Address.Street)
e.AddString("city", u.Address.City)
return nil
}

Expand Down
Binary file modified internal/readme/images/Configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified internal/readme/images/Errors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified internal/readme/images/Formatting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified internal/readme/images/Object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified internal/readme/images/Reflection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified internal/readme/images/Simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified internal/readme/images/SingleLine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified internal/readme/images/ZapConsole.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 44b8f84

Please sign in to comment.