feat: 自动创建日志目录

This commit is contained in:
Mmx233
2022-03-02 22:19:39 +08:00
parent 77474e46b6
commit bf757a2bcc
2 changed files with 13 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import (
"log"
"os"
"runtime"
"strings"
"time"
)
@@ -19,11 +20,17 @@ type loG struct {
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.WriteFile = logFile
c.OutPut = outPut
//日志路径初始化与处理
if !strings.HasSuffix(path, "/") {
path += "/"
}
c.Path = path
return os.MkdirAll(path, os.ModePerm)
}
func (c *loG) time() string {