File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 58
58
stdout : ' DEBUG'
59
59
file : ' DEBUG'
60
60
61
- # operation configuration
61
+ # operation record configuration
62
62
operation :
63
- skip_paths :
63
+ skip-paths :
64
64
- ' /base/login'
65
65
- ' /base/register'
66
- - ' /sysOperationRecord/getSysOperationRecordList'
66
+ - ' /sysOperationRecord/getSysOperationRecordList'
67
+ - ' /sysOperationRecord/deleteSysOperationRecord'
Original file line number Diff line number Diff line change @@ -73,5 +73,5 @@ type Sqlite struct {
73
73
}
74
74
75
75
type Operation struct {
76
- SkipPaths []string `mapstructure: "skip_paths " json:"skip_paths " yaml: "username "`
76
+ SkipPaths []string `mapstructure:"skip-paths " json:"skipPaths " yaml:"skip-paths "`
77
77
}
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package middleware
2
2
3
3
import (
4
4
"bytes"
5
- "fmt"
6
5
"gin-vue-admin/global"
7
6
"gin-vue-admin/model"
8
7
"gin-vue-admin/service"
@@ -35,10 +34,9 @@ func RecordRequestBody() gin.HandlerFunc {
35
34
func OperationRecord () gin.HandlerFunc {
36
35
return gin .LoggerWithConfig (gin.LoggerConfig {
37
36
Formatter : func (param gin.LogFormatterParams ) string {
38
- fmt . Println ( global . GVA_CONFIG . Operation . SkipPaths )
37
+ // 防止加载查询参数,再次过滤
39
38
for _ , v := range global .GVA_CONFIG .Operation .SkipPaths {
40
39
if strings .Contains (param .Path , v ) {
41
- fmt .Println (param .Path )
42
40
return ""
43
41
}
44
42
}
@@ -49,15 +47,15 @@ func OperationRecord() gin.HandlerFunc {
49
47
Status : param .StatusCode ,
50
48
Latency : param .Latency ,
51
49
Agent : param .Request .UserAgent (),
52
- ErrorMessage : string (body ),
50
+ ErrorMessage : param .ErrorMessage ,
51
+ Body : string (body ),
53
52
UserId : int (userId ),
54
53
})
55
54
if err != nil {
56
55
global .GVA_LOG .Error (err )
57
56
}
58
57
return ""
59
58
},
60
- // 暂时没考虑好
61
59
Output : nil ,
62
60
SkipPaths : global .GVA_CONFIG .Operation .SkipPaths ,
63
61
})
Original file line number Diff line number Diff line change @@ -16,5 +16,6 @@ type SysOperationRecord struct {
16
16
Latency time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:''"`
17
17
Agent string `json:"agent" form:"agent" gorm:"column:agent;comment:''"`
18
18
ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:''"`
19
+ Body string `json:"body" form:"body" gorm:"column:body;comment:'请求Body'"`
19
20
UserId int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:''"`
20
21
}
You can’t perform that action at this time.
0 commit comments