Skip to content

scatternoodle/slight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slight

A tiny, zero-dependency slog handler that feels like printf

Overview

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.

Installation

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.

Example

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"))
}

About

A tiny slog handler that feels like printf

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages