增加默认日志文件路径与文件名
This commit is contained in:
parent
267fdf1a4c
commit
551da36ac9
@ -80,6 +80,10 @@ func SetWSServerLogEnable(logPath string, logFile string, logLevel zapcore.Level
|
|||||||
// 传入非法值,默认按小时切割日志
|
// 传入非法值,默认按小时切割日志
|
||||||
splitInterval = DefaultLogSplitInterval
|
splitInterval = DefaultLogSplitInterval
|
||||||
}
|
}
|
||||||
|
if len(logPath) == 0 {
|
||||||
|
logPath = "./logs"
|
||||||
|
}
|
||||||
|
|
||||||
wsc.LogEnable = true
|
wsc.LogEnable = true
|
||||||
wsc.LogPath = logPath
|
wsc.LogPath = logPath
|
||||||
wsc.LogFile = logFile
|
wsc.LogFile = logFile
|
||||||
|
@ -100,6 +100,9 @@ func NewWebsocketServe(wsInstanceList ...abstract.IWebsocket) error {
|
|||||||
if s.conf.LogConsole {
|
if s.conf.LogConsole {
|
||||||
optionList = append(optionList, logger.WithConsoleOutput())
|
optionList = append(optionList, logger.WithConsoleOutput())
|
||||||
}
|
}
|
||||||
|
if len(s.conf.LogFile) == 0 {
|
||||||
|
s.conf.LogFile = wsInstance.GetModuleFlag() + ".log"
|
||||||
|
}
|
||||||
if logConf, err = logger.NewRotateLogConfig(s.conf.LogPath, s.conf.LogFile, logger.WithTimeIntervalType(s.conf.LogSplitInterval)); nil != err {
|
if logConf, err = logger.NewRotateLogConfig(s.conf.LogPath, s.conf.LogFile, logger.WithTimeIntervalType(s.conf.LogSplitInterval)); nil != err {
|
||||||
panic(wsInstance.GetModuleFlag() + " 模块开启了日志记录,日志初始化失败, 失败原因 : " + err.Error())
|
panic(wsInstance.GetModuleFlag() + " 模块开启了日志记录,日志初始化失败, 失败原因 : " + err.Error())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user