logger

package
v0.0.0-...-0012533 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelDefualt logLevel = -1 //未设置
	LogLevelFatal   logLevel = 0  //致命等级(输出致命日志)一般是未知错误,发生了里发报警
	LogLevelError   logLevel = 1  //错误等级(输出错误日志)一般是已知错误,发生了需要处理
	LogLevelWarn    logLevel = 2  //警告等级一般是配置表有错,但不影响正常运行等
	LogLevelInfo    logLevel = 3  //信息等级上线后正常需要看到的日志,报告状态等
	LogLevelDebug   logLevel = 4  //调试等级上线后不需要看到的日志,调试用,可以使用Key来临时开关的日志
)

Variables

This section is empty.

Functions

func Debug

func Debug(logKey LogKeyEnum, params ...interface{})

调试等级上线后不需要看到的日志,调试用,可以使用Key来临时开关的日志

func Debugf

func Debugf(logKey LogKeyEnum, format string, params ...interface{})

调试等级上线后不需要看到的日志,调试用,可以使用Key来临时开关的日志

func Error

func Error(params ...interface{})

错误等级(输出错误日志)一般是已知错误,发生了需要处理

func Errorf

func Errorf(format string, params ...interface{})

错误等级(输出错误日志)一般是已知错误,发生了需要处理

func Fatal

func Fatal(params ...interface{})

致命等级(输出致命日志)一般是未知错误,发生了里发报警

func Fatalf

func Fatalf(format string, params ...interface{})

致命等级(输出致命日志)一般是未知错误,发生了里发报警

func Flush

func Flush()

func GenLogConfigFile

func GenLogConfigFile(cfgpath string)

生成一个默认的日志文件

func Info

func Info(params ...interface{})

信息等级上线后正常需要看到的日志,报告状态等

func Infof

func Infof(format string, params ...interface{})

信息等级上线后正常需要看到的日志,报告状态等

func Init

func Init(cfg string, srvname string, thgo *threads.ThreadGo)

初始化日志系统

func LoggerSetConfig

func LoggerSetConfig(v *LogFileConfig) option

func Warn

func Warn(params ...interface{})

警告等级一般是配置表有错,但不影响正常运行等

func Warnf

func Warnf(format string, params ...interface{})

警告等级一般是配置表有错,但不影响正常运行等

Types

type LogFileConfig

type LogFileConfig struct {
	LogFileName        string   //日志文件名字
	LogFilePath        string   //日志文件路径
	LogFileLevel       logLevel //日志文件等级
	LogFileMaxLine     int      //单个日志文件最大行数
	LogFileMaxNumber   int      //日志文件最大编号(如果为0则不会每个生成间隔内只会产生一个带日期后缀的日志文件,日志文件达到最大行数则不会再写日志)
	LogFileMaxSaveDays int      //日志文件最大保存天数(<1:永久保存 >=1:第二天0点删除 ... 以此类推)
	Keys               []string //Debug时可以输入的Key
}

日志文件配置(如果没有传入新的日志文件配置则使用默认的NewLogFileConfig())

type LogKeyEnum

type LogKeyEnum = string

日志枚举

const (
	//缺省调试日志
	LogKey_Default LogKeyEnum = "Default"
	//Entity有关的调试信息
	LogKey_Entity LogKeyEnum = "Entity"
	//Mysql有关日志
	LogKey_Mysql LogKeyEnum = "Mysql"
	//redis有关日志
	LogKey_Redis LogKeyEnum = "Redis"
	//Gin内日志
	LogKey_GinHttp LogKeyEnum = "Gin"
	//寻路系统日志
	LogKey_PathFinder LogKeyEnum = "PathFinder"
)

type LoggerIO

type LoggerIO struct {
	LogLv logLevel
	Key   LogKeyEnum
}

一般第三方的框架都是可以设置一个支持io.Write接口的对象传入就可以了

func NewLoggerIO

func NewLoggerIO(loglv logLevel, key LogKeyEnum) *LoggerIO

可以挂载到别的框架中

func (*LoggerIO) PAlart

func (this *LoggerIO) PAlart(params ...interface{})

func (*LoggerIO) Write

func (this *LoggerIO) Write(p []byte) (n int, err error)

type LoggerMgr

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

func (*LoggerMgr) Start

func (this *LoggerMgr) Start()

func (*LoggerMgr) Stop

func (this *LoggerMgr) Stop()

Jump to

Keyboard shortcuts

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