Skip to content

Commit

Permalink
docs: add format methods
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Mar 8, 2023
1 parent 2285bce commit 5da9367
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ log.Fatal(err) // this calls os.Exit(1)
log.Print(err) // prints regardless of log level
```

Or use the formatter variant:

```go
format := "%s %d"
log.Debugf(format, "chocolate", 10)
log.Warnf(format, "adding more", 5)
log.Errorf(format, "increasing temp", 420)
log.Fatalf(format, "too hot!", 500) // this calls os.Exit(1)
log.Printf(format, "baking cookies") // prints regardless of log level

// Use these in conjunction with `With(...)` to add more context
log.With("err", err).Errorf("unable to start %s", "oven")
```

### Structured

All the functions above take a message and key-value pairs of anything. The
Expand Down

0 comments on commit 5da9367

Please sign in to comment.