Skip to content

Commit

Permalink
updated code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lmittmann committed May 11, 2023
1 parent d1df6e1 commit e783b15
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ go get github.com/lmittmann/tint

```go
// create a new logger
logger := slog.New(tint.NewHandler(os.Stderr))
logger := slog.New(tint.NewHandler(os.Stderr, nil))

// set global logger with custom options
slog.SetDefault(slog.New(tint.Options{
slog.SetDefault(slog.New(tint.NewHandler(os.Stderr, &tint.Options{
Level: slog.LevelDebug,
TimeFormat: time.Kitchen,
}.NewHandler(os.Stderr)))
})))
```

### Customize
Expand All @@ -45,20 +45,20 @@ for details.

```go
// create a new logger that doesn't write the time
logger := slog.New(tint.Options{
logger := slog.New(tint.NewHandler(os.Stderr, &tint.Options{
ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
if a.Key == slog.TimeKey && len(groups) == 0 {
return slog.Attr{}
}
return a
},
}.NewHandler(os.Stderr))
}))
```

### Windows

ANSI color support in the terminal on Windows can be enabled by using e.g. [`go-colorable`](https://github.com/mattn/go-colorable).

```go
logger := slog.New(tint.NewHandler(colorable.NewColorableStderr()))
logger := slog.New(tint.NewHandler(colorable.NewColorableStderr(), nil))
```

0 comments on commit e783b15

Please sign in to comment.