|
7 | 7 | "os"
|
8 | 8 | "testing"
|
9 | 9 |
|
| 10 | + "go.opencensus.io/trace" |
10 | 11 | "golang.org/x/xerrors"
|
11 | 12 |
|
12 | 13 | "cdr.dev/slog"
|
@@ -48,26 +49,19 @@ func Example_testing() {
|
48 | 49 |
|
49 | 50 | slogtest.Info(t, "my message here",
|
50 | 51 | slog.F("field_name", "something or the other"),
|
51 |
| - slog.F("some_map", slog.M( |
52 |
| - slog.F("nested_fields", "wowow"), |
53 |
| - )), |
54 |
| - slog.Error( |
55 |
| - xerrors.Errorf("wrap1: %w", |
56 |
| - xerrors.Errorf("wrap2: %w", |
57 |
| - io.EOF, |
58 |
| - ), |
59 |
| - ), |
60 |
| - ), |
61 | 52 | )
|
62 | 53 |
|
63 |
| - // t.go:55: 2019-12-05 21:20:31.218 [INFO] <examples_test.go:42> my message here {"field_name": "something or the other", "some_map": {"nested_fields": "wowow"}} ... |
64 |
| - // "error": wrap1: |
65 |
| - // cdr.dev/slog_test.TestExample |
66 |
| - // /Users/nhooyr/src/cdr/slog/examples_test.go:48 |
67 |
| - // - wrap2: |
68 |
| - // cdr.dev/slog_test.TestExample |
69 |
| - // /Users/nhooyr/src/cdr/slog/examples_test.go:49 |
70 |
| - // - EOF |
| 54 | + // t.go:55: 2019-12-05 21:20:31.218 [INFO] <examples_test.go:42> my message here {"field_name": "something or the other"} |
| 55 | +} |
| 56 | + |
| 57 | +func Example_tracing() { |
| 58 | + log := sloghuman.Make(os.Stdout) |
| 59 | + |
| 60 | + ctx, _ := trace.StartSpan(context.Background(), "spanName") |
| 61 | + |
| 62 | + log.Info(ctx, "my msg", slog.F("hello", "hi")) |
| 63 | + |
| 64 | + // 2019-12-09 21:59:48.110 [INFO] <example_test.go:62> my msg {"trace": "f143d018d00de835688453d8dc55c9fd", "span": "f214167bf550afc3", "hello": "hi"} |
71 | 65 | }
|
72 | 66 |
|
73 | 67 | func ExampleWith() {
|
|
0 commit comments