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
- Host: GitHub
- URL: https://github.com/grackleclub/log
- Owner: grackleclub
- License: mit
- Created: 2024-08-31T18:49:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-09T01:53:20.000Z (over 1 year ago)
- Last Synced: 2025-03-31T09:33:33.372Z (over 1 year ago)
- Topics: go, log, logging
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# log
simple structured log wrapper for go, with tint by [lmittmann/tint](https://github.com/lmittmann/tint) 🌈

## 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")
```