pretty

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pretty is a handler for slog that formats messages beautifully.

See: https://betterstack.com/community/guides/logging/logging-in-go/

Index

Constants

This section is empty.

Variables

LevelConf is a mapping of logging levels to their respective names and colors for formatting.

Functions

func NewHandler

func NewHandler(out io.Writer, opts *HandlerOptions) slog.Handler

NewHandler creates a new logging handler pkg/log/slog.Handler with the specified output writer and options.

Types

type HandlerOptions

type HandlerOptions struct {
	SlogOptions *slog.HandlerOptions
	JSON        bool
}

HandlerOptions contains options for configuring a logging handler.

type NameColor

type NameColor struct {
	// contains filtered or unexported fields
}

NameColor represents a combination of a name and a color function for formatting.

type Pretty

type Pretty interface {
	// Handle formats and handles a logging record.
	Handle(ctx context.Context, r slog.Record) error
}

Pretty is an interface for handling logging records with pretty formatting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL