Merge pull request !56 from 黎白南/feat-logx-middle
This commit is contained in:
黎白南 2021-10-08 13:35:19 +00:00 committed by Gitee
commit b168eecbb4
1 changed files with 12 additions and 2 deletions

View File

@ -11,7 +11,12 @@ import (
"time"
)
var (
floor = 3
)
func With(ctx context.Context, p event.ProduceInterface) *upLogger {
floor = 4
return &upLogger{
ctx: ctx,
produce: p,
@ -40,7 +45,12 @@ func (l *upLogger) Print(level string, format string, msg ...interface{}) {
Print(level, format, msg...)
eventMiddle := event.NewEvent(middleMsg.EventNameLog)
eventMiddle.SetValue(middleMsg.EventKeyLog, middleMsg.LogContext{})
eventMiddle.SetValue(middleMsg.EventKeyLog, middleMsg.LogContext{
Level: level,
Data: time.Now(),
Msg: fmt.Sprintf(format, msg...),
Route: findPlace(),
})
l.produce.Call(l.ctx, eventMiddle)
}
@ -80,7 +90,7 @@ func findPlace() string {
var (
place string
i = 0
i = floor
)
for {