Skip to content

Commit 56c5fd9

Browse files
committed
Update docs
1 parent a3fbba1 commit 56c5fd9

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ log := sloghuman.Make(os.Stdout)
4040
log.Info(context.Background(), "my message here",
4141
slog.F("field_name", "something or the other"),
4242
slog.F("some_map", slog.M(
43-
slog.F("nested_fields", "wowow"),
43+
slog.F("nested_fields", time.Date(2000, time.February, 5, 4, 4, 4, 0, time.UTC)),
4444
)),
4545
slog.Error(
4646
xerrors.Errorf("wrap1: %w",
@@ -52,7 +52,7 @@ log.Info(context.Background(), "my message here",
5252
)
5353
```
5454

55-
![Example output screenshot](https://i.imgur.com/7MJM0VE.png)
55+
![Example output screenshot](https://i.imgur.com/KGRmQFo.png)
5656

5757
## Why?
5858

@@ -97,9 +97,7 @@ Here is a list of reasons how we improved on zap with slog.
9797
- zap is hard and confusing to extend. There are too many structures and configuration options.
9898

9999
1. Structured logging of Go structures with `json.Marshal`
100-
- All values will be logged with `json.Marshal` unless they implement `fmt.Stringer` or `error`.
101-
- You can force JSON by using [`slog.ForceJSON`](https://godoc.org/cdr.dev/slog#ForceJSON).
102-
- One may implement [`slog.Value`](https://godoc.org/cdr.dev/slog#Value) to override the representation completely.
100+
- Entire encoding process is documented on [godoc](https://godoc.org/cdr.dev/slog#Map.MarshalJSON).
103101
- With zap, We found ourselves often implementing zap's
104102
[ObjectMarshaler](https://godoc.org/go.uber.org/zap/zapcore#ObjectMarshaler) to log Go structures. This was
105103
verbose and most of the time we ended up only implementing `fmt.Stringer` and using `zap.Stringer` instead.

example_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net"
77
"os"
88
"testing"
9+
"time"
910

1011
"go.opencensus.io/trace"
1112
"golang.org/x/xerrors"
@@ -22,7 +23,7 @@ func Example() {
2223
log.Info(context.Background(), "my message here",
2324
slog.F("field_name", "something or the other"),
2425
slog.F("some_map", slog.M(
25-
slog.F("nested_fields", "wowow"),
26+
slog.F("nested_fields", time.Date(2000, time.February, 5, 4, 4, 4, 0, time.UTC)),
2627
)),
2728
slog.Error(
2829
xerrors.Errorf("wrap1: %w",
@@ -33,7 +34,7 @@ func Example() {
3334
),
3435
)
3536

36-
// 2019-12-09 05:04:53.398 [INFO] <example.go:16> my message here {"field_name": "something or the other", "some_map": {"nested_fields": "wowow"}} ...
37+
// 2019-12-09 05:04:53.398 [INFO] <example.go:16> my message here {"field_name": "something or the other", "some_map": {"nested_fields": "2000-02-05T04:04:04Z"}} ...
3738
// "error": wrap1:
3839
// main.main
3940
// /Users/nhooyr/src/cdr/scratch/example.go:22

0 commit comments

Comments
 (0)