2024-12-03 09:21:00 +08:00
|
|
|
package LOG
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2024-12-13 22:04:56 +08:00
|
|
|
"runtime"
|
2024-12-03 09:21:00 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func DEBUG(text string, msg ...interface{}) {
|
2024-12-27 15:56:59 +08:00
|
|
|
pc, file, line, ok := runtime.Caller(3)
|
|
|
|
if !ok {
|
|
|
|
pc, file, line, ok = runtime.Caller(2)
|
|
|
|
}
|
2024-12-13 22:04:56 +08:00
|
|
|
if ok {
|
|
|
|
funcName := runtime.FuncForPC(pc).Name()
|
|
|
|
log.Printf("[DEBUG] [%s:%d %s()] %s\n", file, line, funcName, fmt.Sprintf(text, msg...))
|
|
|
|
} else {
|
|
|
|
log.Printf("[DEBUG] %s\n", fmt.Sprintf(text, msg...))
|
|
|
|
}
|
2024-12-03 09:21:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func INFO(text string, msg ...interface{}) {
|
|
|
|
msgText := fmt.Sprintf(text, msg...)
|
2024-12-07 17:16:44 +08:00
|
|
|
log.Println("[INFO] ", msgText)
|
2024-12-03 09:21:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func WARN(text string, msg ...interface{}) {
|
|
|
|
msgText := fmt.Sprintf(text, msg...)
|
2024-12-07 17:16:44 +08:00
|
|
|
log.Println("[WARN] ", msgText)
|
2024-12-03 09:21:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func ERROR(text string, msg ...interface{}) {
|
|
|
|
msgText := fmt.Sprintf(text, msg...)
|
|
|
|
log.Println("[ERROR] ", msgText)
|
|
|
|
}
|
|
|
|
|
|
|
|
func FATAL(text string, msg ...interface{}) {
|
|
|
|
msgText := fmt.Sprintf(text, msg...)
|
|
|
|
log.Fatalln("[FATAL] ", msgText)
|
|
|
|
}
|