Skip to content

Commit f666e16

Browse files
committed
update readme and example
1 parent afe81dc commit f666e16

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@ slog.SetDefault(slog.New(ctxslog.NewHandler(slog.NewJSONHandler(os.Stdout, nil))
1717
1818
ctx := ctxslog.WithValue(context.Background(), "AccountID", 123456789)
1919
ctx = ctxslog.WithValue(ctx, "email", "[email protected]")
20+
ctx = ctxslog.WithValue(ctx, "sender", "[email protected]")
2021
2122
slog.InfoContext(ctx, "Info With Context")
22-
23+
fmt.Println()
2324
ctx = ctxslog.WithValues(context.Background(), map[string]interface{}{
24-
"AccountID": 987654321,
25-
"email": "[email protected]",
25+
"AccountID": 987654321,
26+
"email": "[email protected]",
27+
"complexData": ComplexData{
28+
IntField: 123,
29+
StrField: "DEADBEEF",
30+
BoolField: true,
31+
SliceField: []string{"one", "two", "three"},
32+
},
2633
})
2734
2835
slog.ErrorContext(ctx, "Error With Context")

examples/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"fmt"
56
"log/slog"
67
"os"
78

@@ -23,7 +24,7 @@ func main() {
2324
ctx = ctxslog.WithValue(ctx, "sender", "[email protected]")
2425

2526
slog.InfoContext(ctx, "Info With Context")
26-
27+
fmt.Println()
2728
ctx = ctxslog.WithValues(context.Background(), map[string]interface{}{
2829
"AccountID": 987654321,
2930
"email": "[email protected]",

0 commit comments

Comments
 (0)