Go to file
2024-07-20 16:35:22 -07:00
internal Initial Commit 2024-07-20 16:27:46 -07:00
cli.go Initial Commit 2024-07-20 16:27:46 -07:00
common.go Initial Commit 2024-07-20 16:27:46 -07:00
go.mod Initial Commit 2024-07-20 16:27:46 -07:00
go.sum Initial Commit 2024-07-20 16:27:46 -07:00
LICENSE Initial Commit 2024-07-20 16:27:46 -07:00
pretty.go Initial Commit 2024-07-20 16:27:46 -07:00
README.md Initial Commit 2024-07-20 16:27:46 -07:00

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