mirror of
https://github.com/DullJZ/s3-balance.git
synced 2026-09-07 17:06:37 +08:00
Support setting host & recording error req
This commit is contained in:
@@ -87,7 +87,8 @@ type AccessLog struct {
|
||||
Size int64 `gorm:"default:0" json:"size"`
|
||||
ClientIP string `gorm:"size:64" json:"client_ip"`
|
||||
UserAgent string `gorm:"size:512" json:"user_agent"`
|
||||
Success bool `gorm:"default:true" json:"success"`
|
||||
Host string `gorm:"size:255" json:"host"`
|
||||
Success bool `gorm:"not null" json:"success"`
|
||||
ErrorMsg string `gorm:"type:text" json:"error_msg,omitempty"`
|
||||
ResponseTime int64 `gorm:"default:0" json:"response_time"` // 响应时间(毫秒)
|
||||
CreatedAt time.Time `gorm:"index" json:"created_at"`
|
||||
|
||||
@@ -367,13 +367,14 @@ func (s *Service) CleanExpiredSessions() error {
|
||||
}
|
||||
|
||||
// RecordAccessLog 记录访问日志
|
||||
func (s *Service) RecordAccessLog(action, key, bucketName, clientIP, userAgent string, size int64, success bool, errorMsg string, responseTime int64) error {
|
||||
func (s *Service) RecordAccessLog(action, key, bucketName, clientIP, userAgent, host string, size int64, success bool, errorMsg string, responseTime int64) error {
|
||||
log := &AccessLog{
|
||||
Action: action,
|
||||
Key: key,
|
||||
BucketName: bucketName,
|
||||
ClientIP: clientIP,
|
||||
UserAgent: userAgent,
|
||||
Host: host,
|
||||
Size: size,
|
||||
Success: success,
|
||||
ErrorMsg: errorMsg,
|
||||
|
||||
Reference in New Issue
Block a user