log

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const LevelKey = "level"

LevelKey 是记录器级别的键.

Variables

View Source
var (
	// DefaultCaller 是返回文件和行的评估器.
	DefaultCaller = Caller(3)
	// DefaultLogger 是默认记录器.
	DefaultLogger = NewStdLogger("[Titan] ", log.Writer())
	// DefaultCallerLogger 是默认返回文件和行的评估器记录器.
	DefaultCallerLogger = With(DefaultLogger, "caller", DefaultCaller)
	// DefaultTimestamp 是一个返回当前时钟时间的评估器.
	DefaultTimestamp = Timestamp(time.RFC3339)
)

Functions

func Value

func Value(v interface{}) interface{}

Value 返回函数值.

Types

type Level

type Level int8

Level 是记录器级别.

const (
	// DEBUG 用于调试日志
	DEBUG Level = iota
	// INFO 基本日志
	INFO
	// WARNING 用于警告日志
	WARNING
	// ERROR 用于错误日志
	ERROR
	// CRITICAL 用于严重错误日志
	CRITICAL
)

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	Log(pairs ...interface{}) error
}

Logger 是记录器接口.

func Critical

func Critical(log Logger) Logger

func Debug

func Debug(log Logger) Logger

func Error

func Error(log Logger) Logger

func Info

func Info(log Logger) Logger

func MultiLogger

func MultiLogger(logs ...Logger) Logger

MultiLogger 包装多记录器.

func NewStdLogger

func NewStdLogger(prefix string, w io.Writer) Logger

NewStdLogger 带有选项的新标准记录器.

func Warning

func Warning(log Logger) Logger

func With

func With(l Logger, kv ...interface{}) Logger

With 与记录器字段.

type Slf4g

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

Slf4g 是记录器助手.

func NewSlf4g

func NewSlf4g(name string, logger Logger) *Slf4g

NewSlf4g 新的记录器助手.

func (*Slf4g) Critical

func (h *Slf4g) Critical(a ...interface{})

func (*Slf4g) CriticalF

func (h *Slf4g) CriticalF(format string, a ...interface{})

func (*Slf4g) CriticalW

func (h *Slf4g) CriticalW(pairs ...interface{})

func (*Slf4g) Debug

func (h *Slf4g) Debug(a ...interface{})

func (*Slf4g) DebugF

func (h *Slf4g) DebugF(format string, a ...interface{})

func (*Slf4g) DebugW

func (h *Slf4g) DebugW(pairs ...interface{})

func (*Slf4g) Error

func (h *Slf4g) Error(a ...interface{})

func (*Slf4g) ErrorF

func (h *Slf4g) ErrorF(format string, a ...interface{})

func (*Slf4g) ErrorW

func (h *Slf4g) ErrorW(pairs ...interface{})

func (*Slf4g) Info

func (h *Slf4g) Info(a ...interface{})

func (*Slf4g) InfoF

func (h *Slf4g) InfoF(format string, a ...interface{})

func (*Slf4g) InfoW

func (h *Slf4g) InfoW(pairs ...interface{})

func (*Slf4g) Warning

func (h *Slf4g) Warning(a ...interface{})

func (*Slf4g) WarningF

func (h *Slf4g) WarningF(format string, a ...interface{})

func (*Slf4g) WarningW

func (h *Slf4g) WarningW(pairs ...interface{})

type Valuer

type Valuer func() interface{}

Valuer 是返回一个日志值.

func Caller

func Caller(depth int) Valuer

Caller 返回一个Valuer,该Valuer返回一个pkg/file:调用方的行描述.

func Timestamp

func Timestamp(layout string) Valuer

Timestamp 返回具有自定义时间格式的时间戳评估器.

Jump to

Keyboard shortcuts

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