Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evanphx/go-hclog-slog
An adapter from hclog to log/slog
https://github.com/evanphx/go-hclog-slog
Last synced: 3 months ago
JSON representation
An adapter from hclog to log/slog
- Host: GitHub
- URL: https://github.com/evanphx/go-hclog-slog
- Owner: evanphx
- Created: 2023-08-03T18:14:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-17T23:15:40.000Z (6 months ago)
- Last Synced: 2024-08-04T10:03:00.694Z (5 months ago)
- Language: Go
- Size: 14.6 KB
- Stars: 6
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-slog - go-hclog-slog
README
## go-hclog-slog
This is a go module that allows [hclog](https://github.com/hashicorp/go-hclog) to be used with
[slog](https://pkg.go.dev/log/slog), a structured logging module that is
included in Go 1.21 standard library.To create a slog logger from an existing `hclog.Logger` value:
```
var existing hclog.Logger
...
log := slog.New(hclogslog.Adapt(existing))
```
### Limitations
Today, slog provides Time and PC values to the handlers. Currently these are ignored by the adapter because hclog
doesn't provide a way for these to be overriden per-log message. If a future version of hclog
adds the ability to process them per log, this adapter will be updated.