Gloss styles for logs. πͺ΅
It contains a set of styles that can be used with the log package. The following themes are provided:
- catppucchin -- adaptive variants
Catppuccin Latte
Catppuccin FrappΓ©
Catppuccin Macchiato
Catppuccin Mocha
Use go get
to download the dependency.
go get github.com/op/redlog@latest
Then, import
it in Go files:
import (
"github.com/charmbracelet/log"
"github.com/op/redlog"
)
The Red Log package comes with a select few styles of the themes listed above. These are ready to be used straight away.
log.SetStyles(redlog.Catppuccin.Mocha)
slog.SetDefault(slog.New(log.Default()))
If you want to limit the number of dependencies, or make some customisation of the theme yourself, you can directly import and use the theme.
import (
"github.com/charmbracelet/log"
"github.com/op/redlog/pkg/catppuccin"
)
Then initiate the theme the way that suits your needs.
// use an adaptive theme that switches between light and dark depending on the
// terminal's color scheme
variant := catppuccin.Adaptive(catppuccin.Latte, catppuccin.Mocha)
log.SetStyles(catppuccin.Styles(variant))