Skip to content

kyr-go/prettyslog

Repository files navigation

Pretty Slog - A Prettier log/slog

Go Reference Go Report Card Go License: MIT

image image

Install

go get github.com/kyr-go/prettyslog@latest

Basic Usage

package main

import (
	"log/slog"
	"os"

	"github.com/kyr-go/prettyslog"
)

func main() {
	opts := slog.HandlerOptions{
		AddSource: true,
		Level:     slog.LevelDebug,
	}
	slog.SetDefault(slog.New(prettyslog.NewHandler(os.Stdout, &opts)))

	slog.Debug("Debug Message")
	slog.Info("Hello World")
	slog.Warn("Warning Message")
	slog.Error("Error Message")
}

Features

  • Colorize Levels and Group
  • Customizable Levels and Time format using ReplaceAttr