xlog

package
v1.24.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextFormat = "text"
	JsonFormat = "json"
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...slog.Attr)

func Error

func Error(msg string, fields ...slog.Attr)

Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func Info

func Info(msg string, fields ...slog.Attr)

Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func StdLog

func StdLog() *log.Logger

func Warn

func Warn(msg string, fields ...slog.Attr)

Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

Types

type Config

type Config struct {
	slog.HandlerOptions
	OutputPaths []string
	Format      string
	ErrPaths    []string
	ExtFields   map[string]interface{}
}

func DefaultConfig

func DefaultConfig() *Config

type Logger

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

func Default

func Default() *Logger

func NewLogger

func NewLogger(config *Config) (*Logger, error)

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...slog.Attr)

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...slog.Attr)

Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...slog.Attr)

Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func (*Logger) Logger

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

func (*Logger) StdLog

func (l *Logger) StdLog() *log.Logger

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...slog.Attr)

Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

type MultiHandler

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

func NewMultiHandler

func NewMultiHandler(config *Config) (*MultiHandler, error)

func (*MultiHandler) Enabled

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

func (*MultiHandler) Handle

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

func (*MultiHandler) WithAttrs

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

func (*MultiHandler) WithGroup

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

Jump to

Keyboard shortcuts

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