Skip to content

Commit

Permalink
doc: add slog support
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Oct 31, 2023
1 parent 1487437 commit 85d52ab
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ readable logging with batteries included.
- Leveled logging.
- Text, JSON, and Logfmt formatters.
- Store and retrieve logger in and from context.
- Slog handler.
- Standard log adapter.

## Usage
Expand Down Expand Up @@ -306,6 +307,17 @@ startOven(400) // INFO <cookies/oven.go:123> Starting oven degree=400
This will use the _caller_ function (`startOven`) line number instead of the
logging function (`log.Info`) to report the source location.

### Slog Handler

You can use Log as an [`log/slog`](https://pkg.go.dev/log/slog) handler. Just
pass a logger instance to Slog and you're good to go.

```go
handler := log.New(os.Stderr)
logger := slog.New(handler)
logger.Error("meow?")
```

### Standard Log Adapter

Some Go libraries, especially the ones in the standard library, will only accept
Expand Down

0 comments on commit 85d52ab

Please sign in to comment.