summaryrefslogtreecommitdiffstats
path: root/api/admin.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-09-29 15:55:19 -0700
committer=Corey Hulen <corey@hulen.com>2015-09-29 15:55:19 -0700
commit0da42c555943fde2c8623555ca4396a0bbf9ae3e (patch)
tree5532aac376daeef039d0d5ee81a0e41cd99d095d /api/admin.go
parent5e9dccc464590ffe6e05041b76192bb6f12e30c6 (diff)
downloadchat-0da42c555943fde2c8623555ca4396a0bbf9ae3e.tar.gz
chat-0da42c555943fde2c8623555ca4396a0bbf9ae3e.tar.bz2
chat-0da42c555943fde2c8623555ca4396a0bbf9ae3e.zip
PLT-345 adding client side logging
Diffstat (limited to 'api/admin.go')
-rw-r--r--api/admin.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/api/admin.go b/api/admin.go
index 3ef8c12a8..d9714d6d2 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -23,8 +23,10 @@ func InitAdmin(r *mux.Router) {
sr.Handle("/logs", ApiUserRequired(getLogs)).Methods("GET")
sr.Handle("/config", ApiUserRequired(getConfig)).Methods("GET")
sr.Handle("/save_config", ApiUserRequired(saveConfig)).Methods("POST")
- sr.Handle("/client_props", ApiAppHandler(getClientProperties)).Methods("GET")
sr.Handle("/test_email", ApiUserRequired(testEmail)).Methods("POST")
+ sr.Handle("/client_props", ApiAppHandler(getClientProperties)).Methods("GET")
+ sr.Handle("/log_client", ApiAppHandler(logClient)).Methods("POST")
+
}
func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -59,6 +61,26 @@ func getClientProperties(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(model.MapToJson(utils.ClientProperties)))
}
+func logClient(c *Context, w http.ResponseWriter, r *http.Request) {
+ m := model.MapFromJson(r.Body)
+
+ lvl := m["level"]
+ msg := m["message"]
+
+ if len(msg) > 400 {
+ msg = msg[0:399]
+ }
+
+ if lvl == "ERROR" {
+ err := model.NewAppError("client", msg, "")
+ c.LogError(err)
+ }
+
+ rm := make(map[string]string)
+ rm["SUCCESS"] = "true"
+ w.Write([]byte(model.MapToJson(rm)))
+}
+
func getConfig(c *Context, w http.ResponseWriter, r *http.Request) {
if !c.HasSystemAdminPermissions("getConfig") {
return