slogf

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 5 Imported by: 0

README

slogf GoDoc Build Status Coverage Status

Package slogf provides a bridge between the slog and logf packages.

Performance

See also

  • Package slogx with optimized Logger and other useful helpers and extensions to the slog package.
  • Package slogc with optimized helpers for context-centric logging compatible with the slog package.

Documentation

Overview

Package slogf provides a bridge between the slog and logf packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogfLevel

func LogfLevel(level slog.Level) logf.Level

LogfLevel converts slog.Level to logf.Level.

Types

type Handler

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

Handler is a slog.Handler implementation which uses logf.Logger to log records.

func NewHandler

func NewHandler() *Handler

NewHandler returns a new slog.Handler which uses logf.Logger to log records.

func (*Handler) Enabled

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

Enabled returns true if the given level is enabled.

func (*Handler) Handle

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

Handle logs the given record.

func (*Handler) WithAttrs

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

WithAttrs returns a new Handler with the given attributes.

func (*Handler) WithGroup

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

WithGroup returns a new Handler with the given group.

func (*Handler) WithLogger

func (h *Handler) WithLogger(logger *logf.Logger) *Handler

WithLogger returns a new Handler with the given logger.

func (*Handler) WithLoggerFunc

func (h *Handler) WithLoggerFunc(logger func(context.Context) *logf.Logger) *Handler

WithLoggerFunc returns a new Handler with the given logger provider function.

Jump to

Keyboard shortcuts

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