Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/op/redlog

Gloss styles for log πŸͺ΅ and slog πŸ’„
https://github.com/op/redlog

catppuccin go logging pastel slog structured-logging

Last synced: 2 months ago
JSON representation

Gloss styles for log πŸͺ΅ and slog πŸ’„

Awesome Lists containing this project

README

        

# Red Log


Latest Release
Go Docs
Build Status
Go Report Card

Gloss styles for [logs][log]. πŸͺ΅

It contains a set of styles that can be used with the [log] package. The
following themes are provided:

* [catppucchin](https://catppuccin.com) -- adaptive variants

[log]: /charmbracelet/log

## Gallery

*Catppuccin Latte*

catppuccin latte

*Catppuccin FrappΓ©*

catppuccin frappe

*Catppuccin Macchiato*

catppuccin macchiato

*Catppuccin Mocha*

catppuccin mocha

## Usage

Use `go get` to download the dependency.

```bash
go get github.com/op/redlog@latest
```

Then, `import` it in Go files:

```go
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.

```go
log.SetStyles(redlog.Catppuccin.Mocha)
slog.SetDefault(slog.New(log.Default()))
```

## Specific theme

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.

```go
import (
"github.com/charmbracelet/log"
"github.com/op/redlog/pkg/catppuccin"
)
```

Then initiate the theme the way that suits your needs.

```go
// 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))
```