logger

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: GPL-3.0 Imports: 15 Imported by: 6

Documentation

Index

Constants

View Source
const (
	MinLevel = Level(iota)
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
	CriticalLevel

	LevelNameUnknown  = "Unknown"
	LevelNameDebug    = "DEBU"
	LevelNameInfo     = "INFO"
	LevelNameWarn     = "WARN"
	LevelNameError    = "ERRO"
	LevelNameCritical = "CRIT"
)

define levels

Variables

View Source
var LevelColors = map[Level]string{
	DebugLevel:    levelColorDebug,
	InfoLevel:     levelColorInfo,
	WarnLevel:     levelColorWarn,
	ErrorLevel:    levelColorError,
	CriticalLevel: levelColorCritical,
}

LevelColors printer's color

Functions

func ClearSubscribers

func ClearSubscribers(g event.SubscriberGroup)

ClearSubscribers 释放所有的对象

func Critical

func Critical(l Logger, msg string, fields ...interface{})

Critical 异常

func Criticalf

func Criticalf(l Logger, msg string, fields ...interface{})

Criticalf 异常

func Debug

func Debug(l Logger, msg string, fields ...interface{})

Debug 调试

func Debugf

func Debugf(l Logger, msg string, fields ...interface{})

Debugf 调试

func Error

func Error(l Logger, msg string, fields ...interface{})

Error 错误

func Errorf

func Errorf(l Logger, msg string, fields ...interface{})

Errorf 错误

func Info

func Info(l Logger, msg string, fields ...interface{})

Info 信息

func Infof

func Infof(l Logger, msg string, fields ...interface{})

Infof 信息

func RemoveSubscriber

func RemoveSubscriber(g event.SubscriberGroup, ids ...string) error

RemoveSubscriber 删除个人的操作函数

func ReplaceString

func ReplaceString(origin, replacer string) string

ReplaceString 替换字符串

func Stack

func Stack() interface{}

Stack stores a stacktrace under the key "stacktrace".

func Subscriber

func Subscriber(g event.SubscriberGroup, fn func(...interface{})) (event.Subscriber, error)

Subscriber 注册个人的操作函数

func ToLevelName

func ToLevelName(lvl Level) string

ToLevelName 等级转换为名称

func Warn

func Warn(l Logger, msg string, fields ...interface{})

Warn 警告

func Warnf

func Warnf(l Logger, msg string, fields ...interface{})

Warnf 警告

Types

type Caller

type Caller func() interface{}

Caller fileds function

type Event

type Event struct {
	Time     time.Time
	Level    Level
	Prefixes []interface{}
	Fields   []interface{}
}

Event log message

type FileSort

type FileSort []os.FileInfo

FileSort 文件排序

func (FileSort) Len

func (fs FileSort) Len() int

func (FileSort) Less

func (fs FileSort) Less(i, j int) bool

func (FileSort) Swap

func (fs FileSort) Swap(i, j int)

type Level

type Level int32

Level log level

type Logger

type Logger interface {
	Debug(msg string, fields ...interface{})
	Debugf(msg string, fields ...interface{})
	Info(msg string, fields ...interface{})
	Infof(msg string, fields ...interface{})
	Warn(msg string, fields ...interface{})
	Warnf(msg string, fields ...interface{})
	Error(msg string, fields ...interface{})
	Errorf(msg string, fields ...interface{})
	Critical(msg string, fields ...interface{})
	Criticalf(msg string, fields ...interface{})
	With(params ...interface{}) Logger
	WithPrefix(prefixes ...interface{}) Logger

	event.SubscriberGroup
}

Logger 日志对象

func NewLogger

func NewLogger() Logger

NewLogger 获取日志实例

func With

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

With 增加默认的消息

func WithPrefix

func WithPrefix(l Logger, prefixes ...interface{}) Logger

WithPrefix 在最前面增加消息

type MoveFileType

type MoveFileType int

MoveFileType move file type

const (
	MoveFileTypeNothing   MoveFileType = iota // 不移动
	MoveFileTypePerMinite                     // 按分钟移动
	MoveFileTypeHourly                        // 按小时移动
	MoveFileTypeDaily                         // 按天移动
)

MoveFileTypes

type OptionChanWriter

type OptionChanWriter func(*chanWriter)

OptionChanWriter 操作配置函数

func ChanWiterBuffer

func ChanWiterBuffer(buffer int) OptionChanWriter

ChanWiterBuffer 设置Chan的大小

func ChanWiterLevel

func ChanWiterLevel(lvl Level) OptionChanWriter

ChanWiterLevel 设置等级

func ChanWiterSeparator

func ChanWiterSeparator(separator string) OptionChanWriter

ChanWiterSeparator 设置打印分隔符

type OptionFileWriter

type OptionFileWriter func(*fileWriterOptions)

OptionFileWriter 操作配置函数

func FileWiterBuffer

func FileWiterBuffer(buffer int) OptionFileWriter

FileWiterBuffer 设置Chan的大小

func FileWiterFileName

func FileWiterFileName(name string) OptionFileWriter

FileWiterFileName 设置文件名

func FileWiterLevel

func FileWiterLevel(lvl Level) OptionFileWriter

FileWiterLevel 设置等级

func FileWiterMaxBackupFile

func FileWiterMaxBackupFile(num int) OptionFileWriter

FileWiterMaxBackupFile 文件最大数量

func FileWiterMaxLength

func FileWiterMaxLength(length int64) OptionFileWriter

FileWiterMaxLength 设置最大文件大小

func FileWiterMoveFileType

func FileWiterMoveFileType(typ MoveFileType) OptionFileWriter

FileWiterMoveFileType 设置移动文件的类型

func FileWiterRoutings

func FileWiterRoutings(num int) OptionFileWriter

FileWiterRoutings 设置Gouting数量

func FileWiterSeparator

func FileWiterSeparator(separator string) OptionFileWriter

FileWiterSeparator 设置打印分隔符

type Writer

type Writer interface {
	event.Subscriber
}

Writer 写对象

func ChanWriter

func ChanWriter(log Logger, opts ...OptionChanWriter) (Writer, error)

ChanWriter 标准窗体的输出对象

func FileWriter

func FileWriter(log Logger, opts ...OptionFileWriter) (Writer, error)

FileWriter 标准窗体的输出对象

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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