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

https://github.com/grackleclub/log

simple wrapper for go log/slog
https://github.com/grackleclub/log

go log logging

Last synced: 4 months ago
JSON representation

simple wrapper for go log/slog

Awesome Lists containing this project

README

          

# log
simple structured log wrapper for go, with tint by [lmittmann/tint](https://github.com/lmittmann/tint) 🌈

![badge](https://github.com/ddbgio/log/actions/workflows/test.yml/badge.svg)

## examples
```go
import logger "github.com/grackleclub/log"

var log *slog.Logger // a global logger can be set

// If empty handler options are provided, the DEBUG
// env var will determine log level and source info.
_ := os.Setenv("DEBUG", "1")

// No color env var is always respected,
// but no effort is made to autodetect.
_ := os.Unsetenv("NO_COLOR")

log, _ = logger.New(slog.HandlerOptions{})

// Because this is regular slog, you can use log.With
// or attrs or any other slog features.
log = log.With("service", "cool_service")

log.Info("logging initialized", "msg", "hello world")
```