logs

package
v0.0.0-...-710c528 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterLog

func RegisterLog(fun RegisterLogFunc)

func SetLevel

func SetLevel(level Level)

func SetLogPath

func SetLogPath(filepath string, level ...Level)

设置日志路径

func Trace

func Trace(format string, args ...interface{})

调试追踪带文件信息

func TraceCaller

func TraceCaller(format string, args ...interface{})

调试追踪

func WriteLog

func WriteLog(log Logger, level Level, format string, args ...interface{})

WriteLog 写入日志

Types

type Level

type Level = int
const (
	Emergency Level = iota
	Alert
	Critical
	Error
	Warn
	Notice
	Info
	Debug
)

type LogFiles

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

func NewLogFiles

func NewLogFiles(filepath string, t time.Duration, level ...Level) *LogFiles

初始化一个日志集合,filepath日志保存路径,如果为空直接输出到屏幕 t日志文件分割时间,比如每天一个文件或每小时一个文件等

func (*LogFiles) Alert

func (lf *LogFiles) Alert(filename, format string, args ...interface{})

警报

func (*LogFiles) Critical

func (lf *LogFiles) Critical(filename, format string, args ...interface{})

关键

func (*LogFiles) Debug

func (lf *LogFiles) Debug(filename, format string, args ...interface{})

输出

func (*LogFiles) Emergency

func (lf *LogFiles) Emergency(filename, format string, args ...interface{})

紧急

func (*LogFiles) Error

func (lf *LogFiles) Error(filename, format string, args ...interface{})

错误

func (*LogFiles) GetLog

func (lf *LogFiles) GetLog(filename string) Logger

获取指定日志

func (*LogFiles) Info

func (lf *LogFiles) Info(filename, format string, args ...interface{})

输出

func (*LogFiles) Level

func (lf *LogFiles) Level(level Level)

设置输出日志等级

func (*LogFiles) Notice

func (lf *LogFiles) Notice(filename, format string, args ...interface{})

func (*LogFiles) Warning

func (lf *LogFiles) Warning(filename, format string, args ...interface{})

警告

type Logger

type Logger interface {
	io.Writer
	//输出
	Debug(format string, args ...interface{})
	//输出
	Info(format string, args ...interface{})
	//警告
	Warning(format string, args ...interface{})
	//注意
	Notice(format string, args ...interface{})
	//错误
	Error(format string, args ...interface{})
	//关键
	Critical(format string, args ...interface{})
	//警报
	Alert(format string, args ...interface{})
	//紧急
	Emergency(format string, args ...interface{})
}

Logger 日志接口

func GetLogger

func GetLogger(logname string) Logger

获取一个日志

func NewLogger

func NewLogger(level ...Level) Logger

type RegisterLogFunc

type RegisterLogFunc func(log *LogFiles)

注册一个日志获取函数

Jump to

Keyboard shortcuts

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