MCPcopy Index your code
hub / github.com/coder/slog / Example_multiple

Function Example_multiple

example_test.go:77–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75}
76
77func 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
92func ExampleWith() {
93 ctx := slog.With(context.Background(), slog.F("field", 1))

Callers

nothing calls this directly

Calls 6

SinkFunction · 0.92
SinkFunction · 0.92
AppendSinksMethod · 0.80
InfoMethod · 0.80
FatalMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected