41 lines
889 B
Go
Raw Permalink Normal View History

package LOG
import (
"fmt"
"log"
2024-12-13 22:04:56 +08:00
"runtime"
)
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...))
}
}
func INFO(text string, msg ...interface{}) {
msgText := fmt.Sprintf(text, msg...)
2024-12-07 17:16:44 +08:00
log.Println("[INFO] ", msgText)
}
func WARN(text string, msg ...interface{}) {
msgText := fmt.Sprintf(text, msg...)
2024-12-07 17:16:44 +08:00
log.Println("[WARN] ", msgText)
}
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)
}