| 44 | } |
| 45 | |
| 46 | func Example_struct() { |
| 47 | l := slog.Make(sloghuman.Sink(os.Stdout)) |
| 48 | |
| 49 | type hello struct { |
| 50 | Meow int `json:"meow"` |
| 51 | Bar string `json:"bar"` |
| 52 | M time.Time `json:"m"` |
| 53 | } |
| 54 | |
| 55 | l.Info(context.Background(), "check out my structure", |
| 56 | slog.F("hello", hello{ |
| 57 | Meow: 1, |
| 58 | Bar: "barbar", |
| 59 | M: time.Date(2000, time.February, 5, 4, 4, 4, 0, time.UTC), |
| 60 | }), |
| 61 | ) |
| 62 | |
| 63 | // 2019-12-16 17:31:51.769 [INFO] <example_test.go:56> check out my structure {"hello": {"meow": 1, "bar": "barbar", "m": "2000-02-05T04:04:04Z"}} |
| 64 | } |
| 65 | |
| 66 | func Example_testing() { |
| 67 | // Provided by the testing package in tests. |