增加默认日志文件路径与文件名

This commit is contained in:
2021-04-17 23:18:58 +08:00
parent 267fdf1a4c
commit 551da36ac9
2 changed files with 7 additions and 0 deletions

View File

@ -100,6 +100,9 @@ func NewWebsocketServe(wsInstanceList ...abstract.IWebsocket) error {
if s.conf.LogConsole {
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 {
panic(wsInstance.GetModuleFlag() + " 模块开启了日志记录,日志初始化失败, 失败原因 : " + err.Error())
}