prettylog

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: LGPL-2.1 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler represents a type that contains a slog.Handler, a function, a bytes.Buffer, and a sync.Mutex.

func NewHandler

func NewHandler(opts *slog.HandlerOptions, format OutputFormat) *Handler

NewHandler is a function that creates a new instance of the Handler struct

func (*Handler) Enabled

func (h *Handler) Enabled(ctx context.Context, level slog.Level) bool

Enabled checks if the log handler is enabled for the given log level

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, r slog.Record) error

Handle is a method of the Handler struct that handles a slog.Record and returns an error

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new log handler with additional attributes

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) slog.Handler

WithGroup returns a new log handler with the specified group name

type OutputFormat added in v0.0.9

type OutputFormat int

OutputFormat custom type

const (
	JSONFormat OutputFormat = iota
	TextFormat
)

custom

Jump to

Keyboard shortcuts

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