logger

package
v0.21.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

	LevelNameUnknown  = "NULL"
	LevelNameTrace    = "TRAC"
	LevelNameDebug    = "DEBU"
	LevelNameInfo     = "INFO"
	LevelNameWarn     = "WARN"
	LevelNameError    = "ERRO"
	LevelNameCritical = "CRIT"
	LevelNamePanic    = "PANC"
)

define levels

Variables

View Source
var LevelColors = map[Level]string{
	TraceLevel:    levelColorInfo,
	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 LogFarm, fields ...interface{})

Critical 异常

func Criticalf

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

Criticalf 异常

func Debug

func Debug(l LogFarm, fields ...interface{})

Debug 调试

func Debugf

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

Debugf 调试

func Error

func Error(l LogFarm, fields ...interface{})

Error 错误

func Errorf

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

Errorf 错误

func Info

func Info(l LogFarm, fields ...interface{})

Info 信息

func Infof

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

Infof 信息

func Panic added in v0.21.2

func Panic(l LogFarm, fields ...interface{})

Panic 异常

func Panicf added in v0.21.2

func Panicf(l LogFarm, msg string, fields ...interface{})

Panicf 异常

func RemoveSubscriber

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

RemoveSubscriber 删除个人的操作函数

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 LogFarm, fields ...interface{})

Warn 警告

func Warnf

func Warnf(l LogFarm, 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
	Fields []interface{}
}

Event log message

type FileOption added in v0.21.2

type FileOption func(*FileOptions)

FileOption 操作配置函数

func FileBuffer added in v0.21.2

func FileBuffer(buffer int) FileOption

FileBuffer 设置Chan的大小

func FileFileName added in v0.21.2

func FileFileName(name string) FileOption

FileFileName 设置文件名

func FileLevel added in v0.21.2

func FileLevel(lvl Level) FileOption

FileLevel 设置等级

func FileMaxBackupFile added in v0.21.2

func FileMaxBackupFile(num int) FileOption

FileMaxBackupFile 文件最大数量

func FileMaxLength added in v0.21.2

func FileMaxLength(length int64) FileOption

FileMaxLength 设置最大文件大小

func FileMoveFileType added in v0.21.2

func FileMoveFileType(typ MoveFileType) FileOption

FileMoveFileType 设置移动文件的类型

func FilePublisher added in v0.21.2

func FilePublisher(pub Publisher) FileOption

FilePublisher set publisher

func FileSeparator added in v0.21.2

func FileSeparator(separator string) FileOption

FileSeparator 设置打印分隔符

type FileOptions added in v0.21.2

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

FileOptions file options

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 LogFarm added in v0.21.2

type LogFarm interface {
	Debug(kvs ...interface{})
	Debugf(msg string, kvs ...interface{})
	Info(kvs ...interface{})
	Infof(msg string, kvs ...interface{})
	Warn(kvs ...interface{})
	Warnf(msg string, kvs ...interface{})
	Error(kvs ...interface{})
	Errorf(msg string, kvs ...interface{})
	Critical(kvs ...interface{})
	Criticalf(msg string, kvs ...interface{})
	Panic(kvs ...interface{})
	Panicf(msg string, kvs ...interface{})

	Log(keyvals ...interface{}) error
}

LogFarm log functions

type Logger

type Logger interface {
	LogFarm

	event.Subscriber

	SetLevel(lvl Level)
}

Logger 日志对象

func NewFileLogger added in v0.21.2

func NewFileLogger(opts ...FileOption) (Logger, error)

NewFileLogger 标准窗体的输出对象

func NewLogrusLogger added in v0.21.2

func NewLogrusLogger(l logrus.FieldLogger, opts ...LogrusOption) Logger

NewLogrusLogger logrus logger

func NewStdLogger added in v0.21.2

func NewStdLogger(opts ...STDOption) Logger

NewStdLogger new std logger

func WithPrefix

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

WithPrefix with prefix

type LogrusOption added in v0.21.2

type LogrusOption func(*LogrusOptions)

LogrusOption 操作配置函数

func LogrusLevel added in v0.21.2

func LogrusLevel(lvl Level) LogrusOption

LogrusLevel 设置等级

type LogrusOptions added in v0.21.2

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

LogrusOptions options

type MoveFileType

type MoveFileType int

MoveFileType move file type

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

MoveFileTypes

type Publisher added in v0.21.2

type Publisher interface {
	LogFarm

	With(params ...interface{}) Publisher
	WithPrefix(kvs ...interface{}) Publisher

	event.SubscriberGroup
}

Publisher publish some informations

func NewPublisher added in v0.21.2

func NewPublisher() Publisher

NewPublisher new a publisher

type STDOption added in v0.21.2

type STDOption func(*STDOptions)

STDOption option

func STDLevel added in v0.21.2

func STDLevel(lvl Level) STDOption

STDLevel set std logger level

func STDPublisher added in v0.21.2

func STDPublisher(pub Publisher) STDOption

STDPublisher set publisher

func STDWriter added in v0.21.2

func STDWriter(w io.Writer) STDOption

STDWriter io writer

type STDOptions added in v0.21.2

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

STDOptions std options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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