Skip to content

A package that wraps, in a single slog.Handler, an array of other handlers.

License

Notifications You must be signed in to change notification settings

alchemy/multislog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multislog

A package that wraps, in a single slog.Handler, an array of other handlers.

Example usage:

package main

import (
	"log/slog"
	"os"
	"strings"

	"github.com/alchemy/multislog"
)

func main() {
	opts := &slog.HandlerOptions{Level: slog.LevelInfo}
	stdoutHandler := slog.NewTextHandler(os.Stdout, opts)
	sb := &strings.Builder{}
	stringHandler := slog.NewTextHandler(sb, opts)
	handler := multislog.NewHandler(stdoutHandler, stringHandler)
	logger := slog.New(handler)
	logger.Debug("debug message")
	logger.Info("info message")
	logger.Warn("warn message")
	logger.Error("error message")
}

About

A package that wraps, in a single slog.Handler, an array of other handlers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages