Documentation
¶
Index ¶
- Constants
- func CheckKey(logKey LogKeyEnum) bool
- func Debug(logKey LogKeyEnum, params ...interface{})
- func Debugf(logKey LogKeyEnum, format string, params ...interface{})
- func Error(params ...interface{})
- func Errorf(format string, params ...interface{})
- func Fatal(params ...interface{})
- func Fatalf(format string, params ...interface{})
- func Flush()
- func GenLogConfigFile(cfgpath string)
- func Info(params ...interface{})
- func Infof(format string, params ...interface{})
- func Init(cfg string, srvname string, thgo *threads.ThreadGo)
- func IsTest() bool
- func LoggerSetConfig(v *LogFileConfig) option
- func MysqlWarn(params ...interface{})
- func ReLoadKeys(Keys []string)
- func ReLoadLevel(level logLevel)
- func RegisterLogKey(key LogKeyEnum, desc string)
- func ScreenDebug(logKey LogKeyEnum, params ...interface{})
- func Warn(params ...interface{})
- func Warnf(format string, params ...interface{})
- type LogFileConfig
- type LogKeyEnum
- type LoggerIO
- type LoggerMgr
Constants ¶
View Source
const ( LogLevelDefualt logLevel = -1 // 未设置 LogLevelFatal logLevel = 0 // 致命等级(输出致命日志)一般是未知错误,发生了里发报警 LogLevelError logLevel = 1 // 错误等级(输出错误日志)一般是已知错误,发生了需要处理 LogLevelWarn logLevel = 2 // 警告等级一般是配置表有错,但不影响正常运行等 LogLevelInfo logLevel = 3 // 信息等级上线后正常需要看到的日志,报告状态等 LogLevelDebug logLevel = 4 // 调试等级上线后不需要看到的日志,调试用,可以使用Key来临时开关的日志 )
View Source
const (
LOGFILE_INIT_NUMBER int = 0
)
Variables ¶
This section is empty.
Functions ¶
func CheckKey ¶
func CheckKey(logKey LogKeyEnum) bool
CheckKey 检查是否包含指定的日志Key。 参数:
logKey: 日志Key。
返回值:
bool: 是否包含指定Key。
func Debug ¶
func Debug(logKey LogKeyEnum, params ...interface{})
Debug 记录调试日志。 参数:
logKey: 日志Key。 params: 日志内容。
func Debugf ¶
func Debugf(logKey LogKeyEnum, format string, params ...interface{})
Debugf 记录调试日志(格式化字符串)。 参数:
logKey: 日志Key。 format: 日志内容的格式化字符串。 params: 格式化参数。
func Errorf ¶
func Errorf(format string, params ...interface{})
Errorf 记录错误日志(格式化字符串)。 参数:
format: 日志内容的格式化字符串。 params: 格式化参数。
func Fatalf ¶
func Fatalf(format string, params ...interface{})
Fatalf 记录致命错误日志(格式化字符串)。 参数:
format: 日志内容的格式化字符串。 params: 格式化参数。
func GenLogConfigFile ¶
func GenLogConfigFile(cfgpath string)
GenLogConfigFile 生成默认的日志配置文件。 参数:
cfgpath: 配置文件路径。
func Infof ¶
func Infof(format string, params ...interface{})
Infof 记录信息日志(格式化字符串)。 参数:
format: 日志内容的格式化字符串。 params: 格式化参数。
func LoggerSetConfig ¶
func LoggerSetConfig(v *LogFileConfig) option
func RegisterLogKey ¶
func RegisterLogKey(key LogKeyEnum, desc string)
RegisterLogKey 注册日志Key和说明。 参数:
key: 日志Key。 desc: 日志Key的说明。
func ScreenDebug ¶
func ScreenDebug(logKey LogKeyEnum, params ...interface{})
调试等级上线后不需要看到的日志,调试用,可以使用Key来临时开关的日志(这个会受GM 进行筛选)
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 AppendFileInfo bool // 是否增加文件信息 TrimFilePath bool // 是否去除文件的路径 }
LogFileConfig 表示日志文件的配置。
func (*LogFileConfig) GetAtomicFileLevel ¶
func (cfg *LogFileConfig) GetAtomicFileLevel() logLevel
GetAtomicFileLevel 获取日志文件的原子等级。 返回值:
logLevel: 当前日志等级。
type LogKeyEnum ¶
type LogKeyEnum = string
LogKeyEnum 表示日志Key的类型。
const ( //缺省调试日志 LogKey_Default LogKeyEnum = "Default" //Entity有关的调试信息 LogKey_Entity LogKeyEnum = "Entity" // Entity消息发给链接有关 LogKey_EntitySess LogKeyEnum = "EntitySess" //Mysql有关日志 LogKey_Mysql LogKeyEnum = "Mysql" //redis有关日志 LogKey_Redis LogKeyEnum = "Redis" //Gin内日志 LogKey_GinHttp LogKeyEnum = "Gin" //寻路系统日志 LogKey_PathFinder LogKeyEnum = "PathFinder" // 对C++内存的管理 LogKey_Lib LogKeyEnum = "Lib" //移动 LogKey_MoveSys LogKeyEnum = "MoveSys" //消息处理接口相关日志 LogKey_Msg LogKeyEnum = "Msg" // 注册 消息有关 LogKey_RegMsgProc LogKeyEnum = "RegMsgProc" // Kafka 日志 LogKey_LogKafka LogKeyEnum = "Kafka" // etcd 日志 LogKey_Etcd LogKeyEnum = "Etcd" // dbmanager 日志 LogKey_DB LogKeyEnum = "DB" )
type LoggerIO ¶
type LoggerIO struct { LogLv logLevel // 日志等级 Key LogKeyEnum // 日志Key }
LoggerIO 实现 io.Writer 接口的日志适配器。
func NewLoggerIO ¶
func NewLoggerIO(loglv logLevel, key LogKeyEnum) *LoggerIO
NewLoggerIO 创建一个新的 LoggerIO 实例。 参数:
loglv: 日志等级。 key: 日志Key。
返回值:
*LoggerIO: LoggerIO 实例。
Click to show internal directories.
Click to hide internal directories.