/* 输出自动换行 */ func Errorln(args ...interface{}) { logName := utils.GetCurrentTime() + ".error" file, err := os.OpenFile(errorFileDir+logName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777) if err != nil { log.Println(err) return } defer file.Close() New(file).Println(args...) }
func Debugf(format string, args ...interface{}) { logName := utils.GetCurrentTime() + ".debug" file, err := os.OpenFile(debugFileDir+logName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777) if err != nil { log.Println(err) return } defer file.Close() New(file).Printf(format, args...) }
func Infof(format string, args ...interface{}) { //create log file name by current time logName := utils.GetCurrentTime() + ".info" file, err := os.OpenFile(infoFileDir+logName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777) if err != nil { log.Println(err) return } defer file.Close() New(file).Printf(format, args...) }
func Debugln(args ...interface{}) { logName := utils.GetCurrentTime() + ".debug" file, err := os.OpenFile(debugFileDir+logName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777) if err != nil { log.Println(err) return } defer file.Close() // 加上文件调用和行号 _, callerFile, line, ok := runtime.Caller(1) if ok { args = append([]interface{}{filepath.Base(callerFile), ":", line}, args...) } New(file).Println(args...) }