15 Star 88 Fork 24

konyshe / gogo

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
UtilsLog.go 1.74 KB
Copy Edit Raw Blame History
package gogo
import (
"fmt"
"log"
)
type LogProcFunc func(content string)
var (
LogErrorFunc LogProcFunc
LogDebugFunc LogProcFunc
LogInfoFunc LogProcFunc
)
func LogRegistError(handle LogProcFunc) {
LogErrorFunc = handle
}
func LogRegistDebug(handle LogProcFunc) {
LogDebugFunc = handle
}
func LogRegistInfo(handle LogProcFunc) {
LogInfoFunc = handle
}
// LogDebug 日志输出和官方fmt.Print、fmt.Printf使用一致
func LogDebug(a ...interface{}) {
if a[0] != nil {
if LogDebugFunc != nil {
LogDebugFunc(fmt.Sprint(a...))
return
}
log.Println(a...)
}
}
// LogDebugF 日志输出和官方fmt.Print、fmt.Printf使用一致
func LogDebugF(format string, a ...interface{}) {
if a[0] != nil {
if LogDebugFunc != nil {
LogDebugFunc(fmt.Sprintf(format, a...))
return
}
log.Printf(format, a...)
}
}
// LogInfo 日志输出和官方fmt.Print、fmt.Printf使用一致
func LogInfo(a ...interface{}) {
if a[0] != nil {
if LogInfoFunc != nil {
LogInfoFunc(fmt.Sprint(a...))
return
}
log.Println(a...)
}
}
// LogInfoF 日志输出和官方fmt.Print、fmt.Printf使用一致
func LogInfoF(format string, a ...interface{}) {
if a[0] != nil {
if LogInfoFunc != nil {
LogInfoFunc(fmt.Sprintf(format, a...))
return
}
log.Printf(format, a...)
}
}
// LogError 日志输出和官方fmt.Print、fmt.Printf使用一致
func LogError(a ...interface{}) {
if a[0] != nil {
if LogErrorFunc != nil {
LogErrorFunc(fmt.Sprint(a...))
return
}
log.Println(a...)
}
}
// LogErrorF 日志输出和官方fmt.Print、fmt.Printf使用一致
func LogErrorF(format string, a ...interface{}) {
if a[0] != nil {
if LogErrorFunc != nil {
LogErrorFunc(fmt.Sprintf(format, a...))
return
}
log.Printf(format, a...)
}
}
Go
1
https://gitee.com/konyshe/gogo.git
git@gitee.com:konyshe/gogo.git
konyshe
gogo
gogo
v2

Search