@@ -32,7 +32,7 @@ func InitDB(c *md.DBCfg) error { | |||||
if c.ShowLog { //根据配置文件设置日志 | if c.ShowLog { //根据配置文件设置日志 | ||||
Db.ShowSQL(true) //设置是否打印sql | Db.ShowSQL(true) //设置是否打印sql | ||||
Db.Logger().SetLevel(0) //设置日志等级 | Db.Logger().SetLevel(0) //设置日志等级 | ||||
//修改日志文件存放路径文件名是%s.log | |||||
//修改日志文件存放路径文件名是%s.logs | |||||
path := fmt.Sprintf(c.Path, c.Name) | path := fmt.Sprintf(c.Path, c.Name) | ||||
f, err = os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777) | f, err = os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777) | ||||
if err != nil { | if err != nil { | ||||
@@ -26,7 +26,7 @@ func Init(host, name, user, psw string) error { | |||||
cfg.MaxLifetime = 30 | cfg.MaxLifetime = 30 | ||||
cfg.MaxOpenConns = 100 | cfg.MaxOpenConns = 100 | ||||
cfg.MaxIdleConns = 100 | cfg.MaxIdleConns = 100 | ||||
cfg.Path = "logs/%s.log" | |||||
cfg.Path = "logs/%s.logs" | |||||
if err := db.InitDB(&cfg); err != nil { | if err := db.InitDB(&cfg); err != nil { | ||||
return err | return err | ||||
} | } | ||||
@@ -13,7 +13,7 @@ func FileExt(fname string) string { | |||||
} | } | ||||
func FilePutContents(fileName string, content string) { | func FilePutContents(fileName string, content string) { | ||||
fd, _ := os.OpenFile("./tmp/"+fileName+".log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) | |||||
fd, _ := os.OpenFile("./tmp/"+fileName+".logs", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) | |||||
fd_time := time.Now().Format("2006-01-02 15:04:05") | fd_time := time.Now().Format("2006-01-02 15:04:05") | ||||
fd_content := strings.Join([]string{"[", fd_time, "] ", content, "\n"}, "") | fd_content := strings.Join([]string{"[", fd_time, "] ", content, "\n"}, "") | ||||
buf := []byte(fd_content) | buf := []byte(fd_content) | ||||