A tiny, zero-dependency slog handler that feels like printf
Slight provides an extremely simple, lightweight, zero-dependency slog Handler that looks and feels very much like fmt.Printf statements. Wrapping this in a handler allows you to have a light and simple format while allowing you to take advantage of slog's log levels, attribute handling, and bring your own io.Writer.
Please note that this is an extremely basic implementation of the slog.Handler
interface. WithAttrs() and WithGroup() are implemented purely for interface
conformity but are functionally identical to the New() function.
go get github.com/scatternoodle/slight@latest
Optionally, to run unit tests, please use go test with the -race flag, to ensure
thread-safety of the handler is properly verified.
package main
import (
"log/slog"
"os"
"github.com/scatternoodle/slight/slight"
)
func main() {
handler := slight.New(os.Stderr, nil)
logger := slog.New(handler)
logger.Info("Greetings!", slog.String("foo", "bar"))
}