fix: 非debug模式不创建日志目录
This commit is contained in:
1
main.go
1
main.go
@@ -16,7 +16,6 @@ func main() {
|
|||||||
); e != nil {
|
); e != nil {
|
||||||
log.Fatalln("初始化日志失败: ", e)
|
log.Fatalln("初始化日志失败: ", e)
|
||||||
}
|
}
|
||||||
defer util.Log.CatchRecover()
|
|
||||||
|
|
||||||
if global.Flags.RunningDaemon {
|
if global.Flags.RunningDaemon {
|
||||||
//后台挂起模式中
|
//后台挂起模式中
|
||||||
|
|||||||
@@ -27,12 +27,15 @@ func (c *loG) Init(debug, logFile, outPut bool, path string) error {
|
|||||||
c.timeStamp = time.Now().Format("2006.01.02-15.04.05")
|
c.timeStamp = time.Now().Format("2006.01.02-15.04.05")
|
||||||
|
|
||||||
//日志路径初始化与处理
|
//日志路径初始化与处理
|
||||||
|
if c.DebugMode {
|
||||||
if !strings.HasSuffix(path, "/") {
|
if !strings.HasSuffix(path, "/") {
|
||||||
path += "/"
|
path += "/"
|
||||||
}
|
}
|
||||||
c.Path = path
|
c.Path = path
|
||||||
return os.MkdirAll(path, os.ModePerm)
|
return os.MkdirAll(path, os.ModePerm)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *loG) time() string {
|
func (c *loG) time() string {
|
||||||
return time.Now().Format("2006/01/02 15:04:05")
|
return time.Now().Format("2006/01/02 15:04:05")
|
||||||
|
|||||||
Reference in New Issue
Block a user