修改交易服务函数命名;调整 docker compose 脚本;
This commit is contained in:
33
web/tasks/log.go
Normal file
33
web/tasks/log.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/hibiken/asynq"
|
||||
"log/slog"
|
||||
"time"
|
||||
)
|
||||
|
||||
type RequestLog struct {
|
||||
Type string
|
||||
User int32
|
||||
IP string
|
||||
UA string
|
||||
Method string
|
||||
Path string
|
||||
Status int
|
||||
Error string
|
||||
Latency time.Duration
|
||||
Time time.Time
|
||||
}
|
||||
|
||||
func NewRequestLog(data RequestLog) *asynq.Task {
|
||||
var rs, err = json.Marshal(data)
|
||||
if err != nil {
|
||||
slog.Error("日志数据序列化失败", slog.Any("err", err), slog.Any("data", data))
|
||||
return nil
|
||||
}
|
||||
return asynq.NewTask("logs:request", rs)
|
||||
}
|
||||
|
||||
type LoginLog struct {
|
||||
}
|
||||
Reference in New Issue
Block a user