xlog

package
v1.27.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func Default

func Default() *slog.Logger

func DefaultStdLog added in v1.24.7

func DefaultStdLog() *log.Logger

func New added in v1.24.2

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

func NewJsonLogger added in v1.24.2

func NewJsonLogger(out string) (*slog.Logger, error)

func NewTextLogger added in v1.24.2

func NewTextLogger(out string) (*slog.Logger, error)

func StdLog

func StdLog(out, prefix, format string) (*log.Logger, error)

Types

type Config

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

func DefaultConfig

func DefaultConfig() *Config

type Logger

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

func NewLogger

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

func (*Logger) Logger

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

func (*Logger) Write added in v1.24.7

func (l *Logger) Write(p []byte) (int, error)

Write 写入,用于log.New() log.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