log

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = newDefaultLogger()

Functions

func Debug

func Debug(fields Fields, message string)

func Debugf

func Debugf(fields string, message ...interface{})

func Error

func Error(fields Fields, message string)

func Errorf

func Errorf(fields string, message ...interface{})

func Info

func Info(fields Fields, message string)

func Infof

func Infof(fields string, message ...interface{})

func IoWriter

func IoWriter() io.Writer

func Production added in v2.0.2

func Production(opts ...Option)

Production 设置高级日志

func Sync added in v2.0.2

func Sync() error

func Warn

func Warn(fields Fields, message string)

func Warnf

func Warnf(fields string, message ...interface{})

func WithErr

func WithErr(err error, message string)

Types

type Fields

type Fields map[string]interface{}

type ILogger

type ILogger interface {
	Debug(Fields, string)
	Error(Fields, string)
	Info(Fields, string)
	Warn(Fields, string)
	WithErr(error, string)
	Debugf(string, ...interface{})
	Errorf(string, ...interface{})
	Infof(string, ...interface{})
	Warnf(string, ...interface{})
	IoWriter() io.Writer
	Sync() error
}

type Level

type Level string
const (
	PanicLevel Level = "panic"
	FatalLevel Level = "fatal"
	ErrorLevel Level = "error"
	WarnLevel  Level = "warn"
	InfoLevel  Level = "info"
	DebugLevel Level = "debug"
)

type Logger

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

func (*Logger) Debug

func (f *Logger) Debug(fields Fields, message string)

func (*Logger) Debugf

func (f *Logger) Debugf(format string, message ...interface{})

func (*Logger) Error

func (f *Logger) Error(fields Fields, message string)

func (*Logger) Errorf

func (f *Logger) Errorf(format string, message ...interface{})

func (*Logger) Info

func (f *Logger) Info(fields Fields, message string)

func (*Logger) Infof

func (f *Logger) Infof(format string, message ...interface{})

func (*Logger) IoWriter

func (f *Logger) IoWriter() io.Writer

func (*Logger) Sync added in v2.0.2

func (f *Logger) Sync() error

func (*Logger) Warn

func (f *Logger) Warn(fields Fields, message string)

func (*Logger) Warnf

func (f *Logger) Warnf(format string, message ...interface{})

func (*Logger) WithErr

func (f *Logger) WithErr(err error, message string)

type Option

type Option func(c *Options)

func AddCaller added in v2.0.2

func AddCaller() Option

func AddCallerSkip added in v2.0.2

func AddCallerSkip(skipStep int) Option

func WithErrorRotate added in v2.0.2

func WithErrorRotate(size, day, maxBackup int, file string) Option

WithErrorRotate 是否使用滚动日志 size 最大size,默认1M day 最长保留天数 maxBackup 最多保留日志文件数量 file 文件路径

func WithLevel

func WithLevel(level Level) Option

func WithOutputOption

func WithOutputOption(f OutputOption) Option

func WithRotate added in v2.0.2

func WithRotate(size, day, maxBackup int, file string) Option

WithRotate 是否使用滚动日志 size 最大size,默认1M day 最长保留天数 maxBackup 最多保留日志文件数量 file 文件路径

type Options

type Options struct {
	Level         Level
	Out           *OutputOption
	AddCaller     bool
	AddCallerSkip int
}

type OutputOption

type OutputOption struct {
	OutPath   io.Writer
	ErrorPath io.Writer
}

Jump to

Keyboard shortcuts

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