From 3f0ec24dc1c18a550913beba8e742e0dbb4c7b42 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 20 Aug 2015 14:20:39 -0700 Subject: Fixing build --- api/context.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'api/context.go') diff --git a/api/context.go b/api/context.go index e3f279e90..e6439e977 100644 --- a/api/context.go +++ b/api/context.go @@ -195,18 +195,22 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (c *Context) LogAudit(extraInfo string) { - audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - Srv.Store.Audit().Save(audit) + go func() { + audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} + <-Srv.Store.Audit().Save(audit) + }() } func (c *Context) LogAuditWithUserId(userId, extraInfo string) { - if len(c.Session.UserId) > 0 { - extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.Session.UserId) - } + go func() { + if len(c.Session.UserId) > 0 { + extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.Session.UserId) + } - audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - Srv.Store.Audit().Save(audit) + audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} + <-Srv.Store.Audit().Save(audit) + }() } func (c *Context) LogError(err *model.AppError) { -- cgit v1.2.3-1-g7c22 From e4b66c3ff41bcac47f026151a7cb1b19b1217672 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 20 Aug 2015 15:04:37 -0700 Subject: Fixing audit log to wait for confirm --- api/context.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'api/context.go') diff --git a/api/context.go b/api/context.go index e6439e977..8babf85f2 100644 --- a/api/context.go +++ b/api/context.go @@ -195,22 +195,22 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (c *Context) LogAudit(extraInfo string) { - go func() { - audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - <-Srv.Store.Audit().Save(audit) - }() + audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} + if r := <-Srv.Store.Audit().Save(audit); r.Err != nil { + c.LogError(r.Err) + } } func (c *Context) LogAuditWithUserId(userId, extraInfo string) { - go func() { - if len(c.Session.UserId) > 0 { - extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.Session.UserId) - } + if len(c.Session.UserId) > 0 { + extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.Session.UserId) + } - audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - <-Srv.Store.Audit().Save(audit) - }() + audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} + if r := <-Srv.Store.Audit().Save(audit); r.Err != nil { + c.LogError(r.Err) + } } func (c *Context) LogError(err *model.AppError) { -- cgit v1.2.3-1-g7c22