feat: 自动创建日志目录
This commit is contained in:
7
main.go
7
main.go
@@ -4,15 +4,18 @@ import (
|
|||||||
"github.com/Mmx233/BitSrunLoginGo/controllers"
|
"github.com/Mmx233/BitSrunLoginGo/controllers"
|
||||||
"github.com/Mmx233/BitSrunLoginGo/global"
|
"github.com/Mmx233/BitSrunLoginGo/global"
|
||||||
"github.com/Mmx233/BitSrunLoginGo/util"
|
"github.com/Mmx233/BitSrunLoginGo/util"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
util.Log.Init(
|
if e := util.Log.Init(
|
||||||
global.Config.Settings.Debug.Enable,
|
global.Config.Settings.Debug.Enable,
|
||||||
global.Config.Settings.Debug.WriteLog,
|
global.Config.Settings.Debug.WriteLog,
|
||||||
true,
|
true,
|
||||||
global.Config.Settings.Debug.LogPath,
|
global.Config.Settings.Debug.LogPath,
|
||||||
)
|
); e != nil {
|
||||||
|
log.Fatalln("初始化日志失败: ", e)
|
||||||
|
}
|
||||||
defer util.Log.CatchRecover()
|
defer util.Log.CatchRecover()
|
||||||
|
|
||||||
if global.Flags.RunningDaemon {
|
if global.Flags.RunningDaemon {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,11 +20,17 @@ type loG struct {
|
|||||||
|
|
||||||
var Log loG
|
var Log loG
|
||||||
|
|
||||||
func (c *loG) Init(debug, logFile, outPut bool, path string) {
|
func (c *loG) Init(debug, logFile, outPut bool, path string) error {
|
||||||
c.Debug = debug
|
c.Debug = debug
|
||||||
c.WriteFile = logFile
|
c.WriteFile = logFile
|
||||||
c.OutPut = outPut
|
c.OutPut = outPut
|
||||||
|
|
||||||
|
//日志路径初始化与处理
|
||||||
|
if !strings.HasSuffix(path, "/") {
|
||||||
|
path += "/"
|
||||||
|
}
|
||||||
c.Path = path
|
c.Path = path
|
||||||
|
return os.MkdirAll(path, os.ModePerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *loG) time() string {
|
func (c *loG) time() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user