logs

package
v0.0.0-...-e50112c Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelOff    = -1
	LevelNotSet = 0
	LevelFatal  = 1
	LevelError  = 3
	LevelWarn   = 4
	LevelInfo   = 6
	LevelDebug  = 7
	LevelAll    = 9
)

RFC5424 log message levels.

Variables

This section is empty.

Functions

func IsDebugEnable

func IsDebugEnable(logger Logger) bool

func IsErrorEnable

func IsErrorEnable(logger Logger) bool

func IsInfoEnable

func IsInfoEnable(logger Logger) bool

func IsIntLevelEnable

func IsIntLevelEnable(expect, actual int) bool

IsIntLevelEnable 判断是否需要记录日志。

expect: 需要记录的日志等级
actual: 实际的日志等级

func IsLevelEnable

func IsLevelEnable(logger Logger, level int) bool

func IsWarnEnable

func IsWarnEnable(logger Logger) bool

func LevelToStr

func LevelToStr(level int) string

func NewWriter

func NewWriter(logger Logger, level int) io.Writer

func StrToLevel

func StrToLevel(str string) int

func Write

func Write(logger Logger, level int, format string, a ...interface{})

Types

type Chain

type Chain []Logger

func (Chain) Debug

func (this Chain) Debug(format string, a ...interface{})

func (Chain) Error

func (this Chain) Error(format string, a ...interface{})

func (Chain) GetLevel

func (this Chain) GetLevel() int

func (Chain) Info

func (this Chain) Info(format string, a ...interface{})

func (Chain) SetLevel

func (this Chain) SetLevel(level int)

func (Chain) Warn

func (this Chain) Warn(format string, a ...interface{})

type DefaultLogging

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

func (*DefaultLogging) GetLogger

func (this *DefaultLogging) GetLogger() Logger

获取当前对象上设置的 Logger 如果当前对象没有设置,则返回 Empty

func (*DefaultLogging) SetLogger

func (this *DefaultLogging) SetLogger(logger Logger)

为当前对象设置 Logger 如果 logger 为 nil,则会将其置为 Empty

type FieldLogger

type FieldLogger interface {
	Logger

	With(key string, val interface{}) FieldLogger
	WithMulti(map[string]interface{}) FieldLogger
}

type IOLogger

type IOLogger struct {
	W io.Writer
	// contains filtered or unexported fields
}

func NewIOLogger

func NewIOLogger(w io.Writer, level ...int) *IOLogger

func Stderr

func Stderr(level ...int) *IOLogger

func Stdout

func Stdout(level ...int) *IOLogger

func (*IOLogger) Debug

func (this *IOLogger) Debug(format string, a ...interface{})

func (*IOLogger) Error

func (this *IOLogger) Error(format string, a ...interface{})

func (*IOLogger) Fatal

func (this *IOLogger) Fatal(format string, a ...interface{})

func (*IOLogger) GetLevel

func (this *IOLogger) GetLevel() int

func (*IOLogger) Info

func (this *IOLogger) Info(format string, a ...interface{})

func (*IOLogger) SetLevel

func (this *IOLogger) SetLevel(level int)

func (*IOLogger) Warn

func (this *IOLogger) Warn(format string, a ...interface{})

func (*IOLogger) Write

func (this *IOLogger) Write(level int, format string, a ...interface{})

type Logger

type Logger interface {
	GetLevel() int
	SetLevel(level int)

	Fatal(format string, a ...interface{})
	Error(format string, a ...interface{})
	Warn(format string, a ...interface{})
	Info(format string, a ...interface{})
	Debug(format string, a ...interface{})
}
var Default Logger = Stdout()
var Empty Logger = &emptyLogger{}

type LoggerProvider

type LoggerProvider interface {
	// 获取当前对象上设置的 Logger
	// 如果当前对象没有设置,则返回 Empty
	GetLogger() Logger
	// 为当前对象设置 Logger
	// 如果 logger 为 nil,则会将其置为 Empty
	SetLogger(logger Logger)
}

type LoggingStruct

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

func (*LoggingStruct) GetLogger

func (this *LoggingStruct) GetLogger() Logger

获取当前对象上设置的 Logger 如果当前对象没有设置,则返回 Empty

func (*LoggingStruct) SetLogger

func (this *LoggingStruct) SetLogger(logger Logger)

为当前对象设置 Logger 如果 logger 为 nil,则会将其置为 Empty

type WritableLogger

type WritableLogger interface {
	Logger

	Write(level int, format string, a ...interface{})
}

Jump to

Keyboard shortcuts

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