mirror of
https://github.com/ZxwyWebSite/lx-source.git
synced 2025-07-07 06:52:14 +08:00
2024-02-15 v1.0.3-pre
This commit is contained in:
10
init.go
10
init.go
@ -12,6 +12,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ZxwyWebSite/ztool"
|
||||
"github.com/ZxwyWebSite/ztool/logs"
|
||||
"github.com/ZxwyWebSite/ztool/zcypt"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -43,9 +44,14 @@ func loadFileLoger() {
|
||||
if env.Config.Main.LogPath != `` {
|
||||
lg := env.Loger.NewGroup(`FileLoger`)
|
||||
printout := env.Config.Main.Print // || env.Config.Main.Debug
|
||||
_, do, err := env.Loger.SetOutFile(ztool.Str_FastConcat(env.RunPath, env.Config.Main.LogPath), printout)
|
||||
f, do, err := env.Loger.SetOutFile(ztool.Str_FastConcat(env.RunPath, env.Config.Main.LogPath), printout)
|
||||
if err == nil {
|
||||
env.Defer.Add(do)
|
||||
// env.Defer.Add(do)
|
||||
env.Defer.Add(func() { do(); f.Close() })
|
||||
env.Tasker.Add(`flog_flush`, func(loger *logs.Logger, now int64) error {
|
||||
loger.Debug(`已写入文件并清理日志缓存`)
|
||||
return do()
|
||||
}, 3600, false)
|
||||
gin.DefaultWriter = env.Loger.GetOutput()
|
||||
gin.ForceConsoleColor()
|
||||
// lg.Info(`文件日志初始化成功`)
|
||||
|
Reference in New Issue
Block a user