This commit is contained in:
oneao committed 2025-08-16 17:29:46 +08:00
1 parent 2d036f4d95
commit f373cf956d
22 files changed
+568 -280

No files matched your search

@@ -1,17 +1,16 @@
package middleware
import (
"base-framework/pkg/logx"
"base-framework/pkg/router"
"time"
"base-framework/pkg/routinex"
"base-framework/pkg/utils/uid"
)
func Logger() router.HandlerFunc {
return func(c *router.Context) {
start := time.Now()
// 执行后续中间件和处理器
routinex.Set(logx.TrackID, uid.NextID())
c.Next()
elapsed := time.Since(start)
// 即使业务中断,这里也能执行,打印耗时
println("耗时:", elapsed.String())
}
}