func buildLog(basepath, logname, filename string) stdlog.Logger { _, err := os.Stat(basepath) if nil != err { err := os.MkdirAll(basepath, os.ModePerm) if nil != err { panic(err) } } //创建redis的log f, err := os.OpenFile(basepath+"/"+filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm) if nil != err { panic(err) } logger := stdlog.Log(logname) logger.SetOutput(f) return logger }
func buildLog(basepath, logname, filename string) stdlog.Logger { _, err := os.Stat(basepath) if nil != err { err := os.MkdirAll(basepath, os.ModePerm) if nil != err { panic(err) } } //创建redis的log f, err := os.OpenFile(basepath+"/"+filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm) if nil != err { panic(err) } logger := stdlog.Log(logname) logger.SetOutput(f) logger.SetPrefix(func() string { now := time.Now() nt := now.Format("2006-01-02 15:04:05") return nt + "\t" }) return logger }