Skip to content

Commit

Permalink
tweak doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yuseferi committed Nov 8, 2023
1 parent f451598 commit 57b0c7f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Zax is a library that adds context to [Zap Logger](https://github.com/uber-go/za
### Usage:
To add something to the context and carry it along, simply use zap.Set:

ctx = zax.Set(ctx, logger, []zap.Field{zap.String("trace_id", "my-trace-id")})
ctx = zax.Set(ctx, logger, zap.String("trace_id", "my-trace-id"))

To retrieve a logger with the contexted fields, use zax.Get:

Expand All @@ -41,9 +41,9 @@ func main() {
logger, _ := zap.NewProduction()
ctx := context.Background()
s := NewServiceA(logger)
ctx = zax.Set(ctx, logger, zap.String("trace_id", "my-trace-id"))
// and if you want to add multiple of them at once
//ctx = zax.Set(ctx, logger, []zap.Field{zap.String("trace_id", "my-trace-id"),zap.String("span_id", "my-span-id")})
ctx = zax.Set(ctx, logger, zap.String("trace_id", "my-trace-id"))
// and if you want to add multiple of them at once
//ctx = zax.Set(ctx, logger, []zap.Field{zap.String("trace_id", "my-trace-id"),zap.String("span_id", "my-span-id")})
s.funcA(ctx)
}

Expand Down

0 comments on commit 57b0c7f

Please sign in to comment.