wheat-cache/pkg/logx/logx.go

61 lines
990 B
Go

package logx
import (
"fmt"
"gitee.com/timedb/wheatCache/pkg/event"
"runtime"
"time"
)
type logContext struct {
level string
dataStr string
msg string
route string
}
func (l *logger) With(p *event.ProduceInterface) *upLogger {
return &upLogger{}
}
func (l *logger) Print(level string, msg interface{}) {
var (
place string
i = 0
)
for {
_, file, line, _ := runtime.Caller(i)
if line == 0 {
break
}
i++
place = fmt.Sprintf("%s:%d\n%s", file, line, place)
}
datetime := fmt.Sprintf("%s", time.Now())[0:19]
fmt.Println(level, datetime, msg, place)
//_ = &logContext{
// level: level,
// dataStr: datetime,
// msg: fmt.Sprintf("%v", msg),
// route: place,
//}
}
func (l *logger) Debug(msg interface{}) {
l.Print("DEBUG", msg)
}
func (l *logger) Info(msg interface{}) {
l.Print("INFO", msg)
}
func (l *logger) Warn(msg interface{}) {
l.Print("WARN", msg)
}
func (l *logger) Error(msg interface{}) {
l.Print("ERROR", msg)
}