logger

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug added in v0.0.4

func Debug(args ...interface{})

func Debugf added in v0.0.4

func Debugf(fmt string, args ...interface{})

func Error added in v0.0.4

func Error(args ...interface{})

func Errorf added in v0.0.4

func Errorf(fmt string, args ...interface{})

func Fatal added in v0.0.4

func Fatal(args ...interface{})

func Fatalf added in v0.0.4

func Fatalf(fmt string, args ...interface{})

func Info added in v0.0.4

func Info(args ...interface{})

func Infof added in v0.0.4

func Infof(fmt string, args ...interface{})

func Init added in v0.0.4

func Init(log Logger)

func Trace added in v0.0.4

func Trace(args ...interface{})

func Tracef added in v0.0.4

func Tracef(fmt string, args ...interface{})

func UserHook added in v0.0.4

func UserHook(hook Hook)

func Warn added in v0.0.4

func Warn(args ...interface{})

func Warnf added in v0.0.4

func Warnf(fmt string, args ...interface{})

Types

type Hook

type Hook interface {
	logrus.Hook
}

type Level

type Level int8
const (
	// TraceLevel 指定比 debug 更小粒度的日志信息
	TraceLevel Level = iota + 1
	// DebugLevel debug 调试信息, 内容相对更详细
	DebugLevel
	// InfoLevel 默认的日志级别, 通常输出程序正常执行期间的日志
	InfoLevel
	// WarnLevel 警告级别 通常输出值得关注的条目
	WarnLevel
	// ErrorLevel 错误级别 通常是非常值得关注的错误信息
	ErrorLevel
	// FatalLevel 该级别的日志会记录并调用 log.Exit(1), 为最高级别的错误
	FatalLevel
)

func (Level) Enabled

func (l Level) Enabled(lvl Level) bool

Enabled 如果给定的 Level 大于当前 Level 则返回 true

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	Init(...Option) error
	Options() *Options
	// WithFields 添加输出固定字段
	WithFields(map[string]interface{})
	// Hook 添加钩子到日志
	Hook(Hook)
	// Log 输出日志
	Log(Level, ...interface{})
	// Logf 输出带格式化的日志
	Logf(Level, string, ...interface{})
}

func Default added in v0.0.4

func Default() Logger

type Option

type Option func(*Options)

func SetOption

func SetOption(key, value interface{}) Option

func WithLevel

func WithLevel(level Level) Option

type Options

type Options struct {
	Level   Level
	LogName string
	Context context.Context
}

Jump to

Keyboard shortcuts

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