| 17 | ) |
| 18 | |
| 19 | func Example() { |
| 20 | log := slog.Make(sloghuman.Sink(os.Stdout)) |
| 21 | |
| 22 | log.Info(context.Background(), "my message here", |
| 23 | slog.F("field_name", "something or the other"), |
| 24 | slog.F("some_map", slog.M( |
| 25 | slog.F("nested_fields", time.Date(2000, time.February, 5, 4, 4, 4, 0, time.UTC)), |
| 26 | )), |
| 27 | slog.Error( |
| 28 | xerrors.Errorf("wrap1: %w", |
| 29 | xerrors.Errorf("wrap2: %w", |
| 30 | io.EOF, |
| 31 | ), |
| 32 | ), |
| 33 | ), |
| 34 | ) |
| 35 | |
| 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": "2000-02-05T04:04:04Z"}} ... |
| 37 | // "error": wrap1: |
| 38 | // main.main |
| 39 | // /Users/nhooyr/src/cdr/scratch/example.go:22 |
| 40 | // - wrap2: |
| 41 | // main.main |
| 42 | // /Users/nhooyr/src/cdr/scratch/example.go:23 |
| 43 | // - EOF |
| 44 | } |
| 45 | |
| 46 | func Example_struct() { |
| 47 | l := slog.Make(sloghuman.Sink(os.Stdout)) |