xslog

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package xslog provides helpers related to logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg *Config) (*slog.Logger, error)

Types

type Config

type Config struct {
	Verbosity int
	Format    string
}

func NewConfigFromFlags

func NewConfigFromFlags(flags *pflag.FlagSet) *Config

NewConfigFromFlags adds flags to the given flagset, and, after the flagset is parsed by the caller, the flags populate the returned logger config.

type Format

type Format string
const (
	DefaultFormat Format = "default"
	TextFormat    Format = "text"
	JSONFormat    Format = "json"
)

type NoopHandler

type NoopHandler struct{}

NoopHandler is a slog handler that does not perform any logging.

func (*NoopHandler) Enabled

func (n *NoopHandler) Enabled(context.Context, slog.Level) bool

Enabled implements slog.Handler.

func (*NoopHandler) Handle

Handle implements slog.Handler.

func (*NoopHandler) WithAttrs

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

WithAttrs implements slog.Handler.

func (*NoopHandler) WithGroup

func (n *NoopHandler) WithGroup(name string) slog.Handler

WithGroup implements slog.Handler.

Jump to

Keyboard shortcuts

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