Files
platform/web/events/log.go

34 lines
564 B
Go

package events
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 {
}