[CR-458] Enhance Logs Endpoint Message (#12984)
* Make it possible to identify log entries created via the post API endpoints * Clarify wording
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
ac8e3a853c
Коммит
501da809f3
@@ -262,14 +262,16 @@ func postLog(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
msg = msg[0:399]
|
msg = msg[0:399]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg = "Client Logs API Endpoint Message: " + msg
|
||||||
|
fields := []mlog.Field{
|
||||||
|
mlog.String("type", "client_message"),
|
||||||
|
mlog.String("user_agent", c.App.UserAgent),
|
||||||
|
}
|
||||||
|
|
||||||
if !forceToDebug && lvl == "ERROR" {
|
if !forceToDebug && lvl == "ERROR" {
|
||||||
err := &model.AppError{}
|
mlog.Error(msg, fields...)
|
||||||
err.Message = msg
|
|
||||||
err.Id = msg
|
|
||||||
err.Where = "client"
|
|
||||||
c.LogError(err)
|
|
||||||
} else {
|
} else {
|
||||||
mlog.Debug("message", mlog.String("message", msg))
|
mlog.Debug(msg, fields...)
|
||||||
}
|
}
|
||||||
|
|
||||||
m["message"] = msg
|
m["message"] = msg
|
||||||
|
|||||||
@@ -283,6 +283,13 @@ func TestPostLog(t *testing.T) {
|
|||||||
_, resp := Client.PostLog(message)
|
_, resp := Client.PostLog(message)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
|
*th.App.Config().ServiceSettings.EnableDeveloper = false
|
||||||
|
|
||||||
|
_, resp = Client.PostLog(message)
|
||||||
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
|
*th.App.Config().ServiceSettings.EnableDeveloper = true
|
||||||
|
|
||||||
Client.Logout()
|
Client.Logout()
|
||||||
|
|
||||||
_, resp = Client.PostLog(message)
|
_, resp = Client.PostLog(message)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user