logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(i ...any)

func Debugf

func Debugf(format string, i ...any)

func Err

func Err(i ...any)

func Errf

func Errf(format string, i ...any)

func Info

func Info(i ...any)

func Infof

func Infof(format string, i ...any)

func PartCaller

func PartCaller(shortFile bool) *partCaller

func PartDateTime

func PartDateTime(layout string) *partDateTime

func PartKV

func PartKV(k, v any) *partString

func PartLevel

func PartLevel() *partLevel

func PartMessage

func PartMessage() *partMessage

func PartSince

func PartSince() *partSince

func PartString

func PartString(raw string) *partString

func SetDefault

func SetDefault(l *Logger)

func Warn

func Warn(i ...any)

func Warnf

func Warnf(format string, i ...any)

Types

type Args

type Args struct {
	Level  Level
	Msg    string
	Time   time.Time
	Buffer buffer
	PC     uintptr
}

type DailyWriter

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

func NewDailyWriter

func NewDailyWriter(folder, prefix string) *DailyWriter

func (*DailyWriter) Write

func (dw *DailyWriter) Write(p []byte) (n int, err error)

type ILogger

type ILogger interface {
	Debug(i ...any)
	Debugf(format string, i ...any)
	Info(i ...any)
	Infof(format string, i ...any)
	Warn(i ...any)
	Warnf(format string, i ...any)
	Err(i ...any)
	Errf(format string, i ...any)
	With(parts ...any) ILogger
}

func With

func With(parts ...any) ILogger

type IPart

type IPart interface {
	Output(args *Args)
}

type Level

type Level int8
const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
)

type Logger

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

func Default

func Default() *Logger

func New

func New() *Logger

写到控制台

func NewDailyLogger

func NewDailyLogger(folder, prefix string) *Logger

按日期写入文件

func NewLogger

func NewLogger(options ...OptionFunc) *Logger

func (*Logger) Debug

func (l *Logger) Debug(i ...any)

func (*Logger) Debugf

func (l *Logger) Debugf(format string, i ...any)

func (*Logger) Err

func (l *Logger) Err(i ...any)

func (*Logger) Errf

func (l *Logger) Errf(format string, i ...any)

func (*Logger) Info

func (l *Logger) Info(i ...any)

func (*Logger) Infof

func (l *Logger) Infof(format string, i ...any)

func (*Logger) Log

func (l *Logger) Log(level Level, format string, msgs []any)

func (*Logger) Warn

func (l *Logger) Warn(i ...any)

func (*Logger) Warnf

func (l *Logger) Warnf(format string, i ...any)

func (*Logger) With

func (l *Logger) With(args ...any) ILogger

func (*Logger) Write

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

type OptionFunc

type OptionFunc func(l *Logger)

func OptLevel

func OptLevel(lv Level) OptionFunc

func OptOutput

func OptOutput(o io.Writer) OptionFunc

func OptPart

func OptPart(parts ...IPart) OptionFunc

Jump to

Keyboard shortcuts

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