Beispiel #1
0
/*
输出自动换行
*/
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...)
}
Beispiel #2
0
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...)
}
Beispiel #3
0
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...)
}
Beispiel #4
0
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...)
}