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

Function Example

example_test.go:19–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17)
18
19func 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
46func Example_struct() {
47 l := slog.Make(sloghuman.Sink(os.Stdout))

Callers

nothing calls this directly

Calls 4

SinkFunction · 0.92
InfoMethod · 0.80
ErrorfMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected