[CR-458] Enhance Logs Endpoint Message (#12984)

* Make it possible to identify log entries created via the post API endpoints

* Clarify wording
Этот коммит содержится в:
Daniel Schalla
2019-11-04 19:03:59 +01:00
коммит произвёл Christopher Speller
родитель ac8e3a853c
Коммит 501da809f3
2 изменённых файлов: 15 добавлений и 6 удалений

Просмотреть файл

@@ -262,14 +262,16 @@ func postLog(c *Context, w http.ResponseWriter, r *http.Request) {
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" {
err := &model.AppError{}
err.Message = msg
err.Id = msg
err.Where = "client"
c.LogError(err)
mlog.Error(msg, fields...)
} else {
mlog.Debug("message", mlog.String("message", msg))
mlog.Debug(msg, fields...)
}
m["message"] = msg

Просмотреть файл

@@ -283,6 +283,13 @@ func TestPostLog(t *testing.T) {
_, resp := Client.PostLog(message)
CheckNoError(t, resp)
*th.App.Config().ServiceSettings.EnableDeveloper = false
_, resp = Client.PostLog(message)
CheckNoError(t, resp)
*th.App.Config().ServiceSettings.EnableDeveloper = true
Client.Logout()
_, resp = Client.PostLog(message)