mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-14 05:03:49 +08:00
tt
This commit is contained in:
45
hotgo-server/app/hook/hook.go
Normal file
45
hotgo-server/app/hook/hook.go
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2022 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package hook
|
||||
|
||||
import (
|
||||
"github.com/bufanyun/hotgo/app/com"
|
||||
"github.com/bufanyun/hotgo/app/service/sysService"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type (
|
||||
// sHook is service struct of module Hook.
|
||||
sHook struct{}
|
||||
)
|
||||
|
||||
var (
|
||||
// insHook is the instance of service Hook.
|
||||
insHook = sHook{}
|
||||
)
|
||||
|
||||
// Hook returns the interface of Hook service.
|
||||
func Instance() *sHook {
|
||||
return &insHook
|
||||
}
|
||||
|
||||
//
|
||||
// @Title 全局日志
|
||||
// @Description
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @Param r
|
||||
//
|
||||
func (s *sHook) GlobalLog(r *ghttp.Request) {
|
||||
var (
|
||||
ctx = r.Context()
|
||||
)
|
||||
|
||||
com.Context.SetTakeUpTime(ctx, gtime.TimestampMilli()-r.EnterTime)
|
||||
|
||||
go sysService.Log.AutoLog(ctx)
|
||||
}
|
||||
Reference in New Issue
Block a user