igo_log

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatLogMsgToStr

func FormatLogMsgToStr(logMsg *LogMsg) *string

通过日志消息转换为日志文本

func NewLogConfig

func NewLogConfig() *_Config

获取默认配置

func NewOutFile

func NewOutFile() *_FileOut

获取文件输出

func NewOutStd

func NewOutStd() *_StdOut

获取标准输出

Types

type LogExitHook

type LogExitHook interface {
	ReceiveLogExit(code int)
}

日志退出钩子

type LogLevel

type LogLevel uint8

日志级别

const (
	LevelTrace LogLevel = iota
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

func (LogLevel) Color

func (logLevel LogLevel) Color() string

日志级别颜色

func (LogLevel) String

func (logLevel LogLevel) String() string

日志级别字符串

type LogMsg

type LogMsg struct {
	Time     time.Time     // 产生时间
	LineCode string        // 产生日志的代码行
	Level    LogLevel      // 日志级别
	Format   string        // 格式化文本
	Args     []interface{} // 格式化参数
	Config   *_Config      // 日志配置
}

日志消息体

type LogMsgHook

type LogMsgHook interface {
	ReceiveLogMsg(logMsg *LogMsg) error
}

日志钩子

type Logger

type Logger interface {
	Trace(format string, args ...interface{})
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Error(format string, args ...interface{})
	Fatal(format string, args ...interface{})
	AddLogMsgHook(hook LogMsgHook)
	Exit(code int)
	AddLogExitHook(hook LogExitHook)
}

日志API

func GetLogger

func GetLogger() Logger

func NewLog

func NewLog(config *_Config) Logger

创建一个日志实例 如果实例已经存在,则先退出已有实例后创建一个新的实例

Jump to

Keyboard shortcuts

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