[MM-24856] User request specific loggers in channels/api4/system.go (#24881)
* replace global mlog with local c.Logger and setInvalidParam with setInvalidParamWithErr if relevant Signed-off-by: Deepayan Mukherjee <deepayanmukherjee1312@gmail.com> * replace global mlog.Info with local c.Logger.Info Signed-off-by: Deepayan Mukherjee <deepayanmukherjee1312@gmail.com> --------- Signed-off-by: Deepayan Mukherjee <deepayanmukherjee1312@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
13c05a571f
Коммит
77ee4d93b7
@@ -146,7 +146,7 @@ func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
actualGoroutines := runtime.NumGoroutine()
|
actualGoroutines := runtime.NumGoroutine()
|
||||||
if *c.App.Config().ServiceSettings.GoroutineHealthThreshold > 0 && actualGoroutines >= *c.App.Config().ServiceSettings.GoroutineHealthThreshold {
|
if *c.App.Config().ServiceSettings.GoroutineHealthThreshold > 0 && actualGoroutines >= *c.App.Config().ServiceSettings.GoroutineHealthThreshold {
|
||||||
mlog.Warn("The number of running goroutines is over the health threshold", mlog.Int("goroutines", actualGoroutines), mlog.Int("health_threshold", *c.App.Config().ServiceSettings.GoroutineHealthThreshold))
|
c.Logger.Warn("The number of running goroutines is over the health threshold", mlog.Int("goroutines", actualGoroutines), mlog.Int("health_threshold", *c.App.Config().ServiceSettings.GoroutineHealthThreshold))
|
||||||
s[model.STATUS] = model.StatusUnhealthy
|
s[model.STATUS] = model.StatusUnhealthy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,14 +159,14 @@ func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
writeErr := c.App.DBHealthCheckWrite()
|
writeErr := c.App.DBHealthCheckWrite()
|
||||||
if writeErr != nil {
|
if writeErr != nil {
|
||||||
mlog.Warn("Unable to write to database.", mlog.Err(writeErr))
|
c.Logger.Warn("Unable to write to database.", mlog.Err(writeErr))
|
||||||
s[dbStatusKey] = model.StatusUnhealthy
|
s[dbStatusKey] = model.StatusUnhealthy
|
||||||
s[model.STATUS] = model.StatusUnhealthy
|
s[model.STATUS] = model.StatusUnhealthy
|
||||||
}
|
}
|
||||||
|
|
||||||
writeErr = c.App.DBHealthCheckDelete()
|
writeErr = c.App.DBHealthCheckDelete()
|
||||||
if writeErr != nil {
|
if writeErr != nil {
|
||||||
mlog.Warn("Unable to remove ping health check value from database.", mlog.Err(writeErr))
|
c.Logger.Warn("Unable to remove ping health check value from database.", mlog.Err(writeErr))
|
||||||
s[dbStatusKey] = model.StatusUnhealthy
|
s[dbStatusKey] = model.StatusUnhealthy
|
||||||
s[model.STATUS] = model.StatusUnhealthy
|
s[model.STATUS] = model.StatusUnhealthy
|
||||||
}
|
}
|
||||||
@@ -366,7 +366,7 @@ func queryLogs(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
if err2 == nil {
|
if err2 == nil {
|
||||||
logsJSON[node] = append(logsJSON[node], result)
|
logsJSON[node] = append(logsJSON[node], result)
|
||||||
} else {
|
} else {
|
||||||
mlog.Warn("Error parsing log line in Server Logs")
|
c.Logger.Warn("Error parsing log line in Server Logs")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -703,7 +703,7 @@ func setServerBusy(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
audit.AddEventParameter(auditRec, "seconds", i)
|
audit.AddEventParameter(auditRec, "seconds", i)
|
||||||
|
|
||||||
c.App.Srv().Platform().Busy.Set(time.Second * time.Duration(i))
|
c.App.Srv().Platform().Busy.Set(time.Second * time.Duration(i))
|
||||||
mlog.Warn("server busy state activated - non-critical services disabled", mlog.Int64("seconds", i))
|
c.Logger.Warn("server busy state activated - non-critical services disabled", mlog.Int64("seconds", i))
|
||||||
|
|
||||||
auditRec.Success()
|
auditRec.Success()
|
||||||
ReturnStatusOK(w)
|
ReturnStatusOK(w)
|
||||||
@@ -719,7 +719,7 @@ func clearServerBusy(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
defer c.LogAuditRec(auditRec)
|
defer c.LogAuditRec(auditRec)
|
||||||
|
|
||||||
c.App.Srv().Platform().Busy.Clear()
|
c.App.Srv().Platform().Busy.Clear()
|
||||||
mlog.Info("server busy state cleared - non-critical services enabled")
|
c.Logger.Info("server busy state cleared - non-critical services enabled")
|
||||||
|
|
||||||
auditRec.Success()
|
auditRec.Success()
|
||||||
ReturnStatusOK(w)
|
ReturnStatusOK(w)
|
||||||
@@ -735,11 +735,11 @@ func getServerBusyExpires(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
// along with doing some computations.
|
// along with doing some computations.
|
||||||
sbsJSON, jsonErr := c.App.Srv().Platform().Busy.ToJSON()
|
sbsJSON, jsonErr := c.App.Srv().Platform().Busy.ToJSON()
|
||||||
if jsonErr != nil {
|
if jsonErr != nil {
|
||||||
mlog.Warn(jsonErr.Error())
|
c.Logger.Warn(jsonErr.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := w.Write(sbsJSON); err != nil {
|
if _, err := w.Write(sbsJSON); err != nil {
|
||||||
mlog.Warn("Error while writing response", mlog.Err(err))
|
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,7 +947,7 @@ func getProductNotices(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
client, parseError := model.NoticeClientTypeFromString(r.URL.Query().Get("client"))
|
client, parseError := model.NoticeClientTypeFromString(r.URL.Query().Get("client"))
|
||||||
if parseError != nil {
|
if parseError != nil {
|
||||||
c.SetInvalidParam("client")
|
c.SetInvalidParamWithErr("client", parseError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
clientVersion := r.URL.Query().Get("clientVersion")
|
clientVersion := r.URL.Query().Get("clientVersion")
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user