logx

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextFormat = "TEXT"
	JSONFormat = "JSON"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger is a simple slog wrapper

func New

func New(opts ...Option) (*Logger, error)

New return a logger with options

func NewJsonLogger

func NewJsonLogger(output string, level string, source bool) (*Logger, error)

NewJsonLogger return a json logger

func NewTextLogger

func NewTextLogger(output string, level string, source bool) (*Logger, error)

NewTextLogger return a text logger

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Level

func (l *Logger) Level() slog.Level

func (*Logger) Slog

func (l *Logger) Slog() *slog.Logger

func (*Logger) Writer added in v1.2.0

func (l *Logger) Writer() io.Writer

type Option

type Option func(options *Options)

func WithFormat

func WithFormat(format string) Option

func WithLevel

func WithLevel(level string) Option

func WithOutput

func WithOutput(output string) Option

func WithReplaceAttr

func WithReplaceAttr(ReplaceAttr func(groups []string, a slog.Attr) slog.Attr) Option

func WithSource

func WithSource(source bool) Option

type Options

type Options struct {
	Output string `mapstructure:"output"`
	Level  string `mapstructure:"level"`
	Format string `mapstructure:"format"`
	Source bool   `mapstructure:"source"`

	ReplaceAttr func(groups []string, a slog.Attr) slog.Attr
}

Options represents logger configuration

Jump to

Keyboard shortcuts

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