log

package
v0.0.0-...-70f3c33 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: BSD-3-Clause Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	LevelTrace = slog.Level(-8)
	LevelDebug = slog.LevelDebug
	LevelInfo  = slog.LevelInfo
	LevelWarn  = slog.LevelWarn
	LevelError = slog.LevelError
)
View Source
const (
	StdOut = "stdout"
	StdErr = "stderr"

	HourPattern = ".%Y%m%d%H"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Trace(msg string, attrs ...slog.Attr)
	Debug(msg string, attrs ...slog.Attr)
	Info(msg string, attrs ...slog.Attr)
	Warn(msg string, attrs ...slog.Attr)
	Error(msg string, attrs ...slog.Attr)
	SetLevel(level slog.Level)

	WithOut(attrs ...slog.Attr) Logger
	WithErr(attrs ...slog.Attr) Logger
}

type Option

type Option func(*option)

func WithErrFile

func WithErrFile(out string) Option

func WithJsonFormat

func WithJsonFormat() Option

func WithLevel

func WithLevel(lvl string) Option

func WithOutFile

func WithOutFile(out string) Option

func WithSkipCaller

func WithSkipCaller(skip int) Option

func WithTimeRotate

func WithTimeRotate(pattern string, maxAge time.Duration, rotateTime time.Duration) Option

type SLogger

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

func NewSLogger

func NewSLogger(opts ...Option) *SLogger

func (*SLogger) Debug

func (d *SLogger) Debug(msg string, attrs ...slog.Attr)

Debug implements Logger.

func (*SLogger) Error

func (d *SLogger) Error(msg string, attrs ...slog.Attr)

Error implements Logger.

func (*SLogger) Info

func (d *SLogger) Info(msg string, attrs ...slog.Attr)

Info implements Logger.

func (*SLogger) SetLevel

func (d *SLogger) SetLevel(level slog.Level)

SetLevel implements Logger.

func (*SLogger) Trace

func (d *SLogger) Trace(msg string, attrs ...slog.Attr)

Trace implements Logger.

func (*SLogger) Warn

func (d *SLogger) Warn(msg string, attrs ...slog.Attr)

Warn implements Logger.

func (*SLogger) WithErr

func (d *SLogger) WithErr(attrs ...slog.Attr) Logger

func (*SLogger) WithOut

func (d *SLogger) WithOut(attrs ...slog.Attr) Logger

Jump to

Keyboard shortcuts

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