改进操作日志

This commit is contained in:
GoEdgeLab
2020-11-20 15:32:42 +08:00
parent 60ba3e0a05
commit fc459a50b9
142 changed files with 230 additions and 100 deletions

View File

@@ -78,12 +78,25 @@ func (this *ParentAction) AdminId() int64 {
}
func (this *ParentAction) CreateLog(level string, description string, args ...interface{}) {
err := models.SharedLogDAO.CreateAdminLog(this.AdminContext(), level, this.Request.URL.Path, fmt.Sprintf(description, args...), this.RequestRemoteIP())
desc := fmt.Sprintf(description, args...)
if level == oplogs.LevelInfo {
if this.Code != 200 {
level = oplogs.LevelWarn
if len(this.Message) > 0 {
desc += " 失败:" + this.Message
}
}
}
err := models.SharedLogDAO.CreateAdminLog(this.AdminContext(), level, this.Request.URL.Path, desc, this.RequestRemoteIP())
if err != nil {
utils.PrintError(err)
}
}
func (this *ParentAction) CreateLogInfo(description string, args ...interface{}) {
this.CreateLog(oplogs.LevelInfo, description, args...)
}
// 获取RPC
func (this *ParentAction) RPC() *rpc.RPCClient {
if this.rpcClient != nil {