Skip to content

Elara6331/loggers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loggers

Loggers is a collection of log/slog handlers that pretty print logs, similar to Zerolog's ConsoleWriter, but without sacrificing any performance.

Example

package main

import (
	"log/slog"
	"os"
	"strconv"

	"go.elara.ws/loggers"
)

const input = "hello"

func main() {
	log := slog.New(loggers.NewPretty(os.Stdout, loggers.Options{
		Level: slog.LevelDebug,
		ShowCaller: true,
	}))

	i, err := strconv.Atoi(input)
	if err != nil {
		log.Error(
			"Couldn't convert to integer",
			slog.String("input", input),
			slog.Any("error", err),
		)
		return
	}

	log.Info(
		"Converted to integer!",
		slog.Int("output", i),
	)
}

Releases

No releases published

Packages

No packages published

Languages