Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
shangxuejin committed Feb 22, 2023
1 parent ba200df commit e392bdc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ func logoutf(logger *Logger, level Level) func(ctx context.Context, format strin

func cost(logger *Logger, level Level) func(ctx context.Context, msg ...interface{}) func() {
return func(ctx context.Context, msg ...interface{}) func() {
logger.output(ctx, level, "%v start...", msg...)
s := append(msg, "start...")
logger.output(ctx, level, "", s...)
start := time.Now()
return func() {
logger.output(ctx, level, "%v cost "+
time.Now().Sub(start).Truncate(time.Millisecond).String(), msg...)
e = append(msg, "cost", time.Since(start).Truncate(time.Millisecond).String())
logger.output(ctx, level, "", msg...)
}
}
}
Expand Down

0 comments on commit e392bdc

Please sign in to comment.