| 75 | } |
| 76 | |
| 77 | func Example_multiple() { |
| 78 | l := slog.Make(sloghuman.Sink(os.Stdout)) |
| 79 | |
| 80 | f, err := os.OpenFile("stackdriver", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0o644) |
| 81 | if err != nil { |
| 82 | l.Fatal(context.Background(), "failed to open stackdriver log file", slog.Error(err)) |
| 83 | } |
| 84 | |
| 85 | l = l.AppendSinks(slogstackdriver.Sink(f)) |
| 86 | |
| 87 | l.Info(context.Background(), "log to stdout and stackdriver") |
| 88 | |
| 89 | // 2019-12-07 20:59:55.790 [INFO] log to stdout and stackdriver |
| 90 | } |
| 91 | |
| 92 | func ExampleWith() { |
| 93 | ctx := slog.With(context.Background(), slog.F("field", 1)) |