From 686c2fbab7607d42183ae685a27ea3d7dce8c3f6 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Fri, 27 Apr 2018 12:49:45 -0700 Subject: Structured logging (#8673) * Implementing structured logging * Changes to en.json to allow refactor to run. * Fixing global logger * Structured logger initalization. * Add caller. * Do some log redirection. * Auto refactor * Cleaning up l4g reference and removing dependancy. * Removing junk. * Copyright headers. * Fixing tests * Revert "Changes to en.json to allow refactor to run." This reverts commit fd8249e99bcad0231e6ea65cd77c32aae9a54026. * Fixing some auto refactor strangeness and typo. * Making keys more human readable. --- app/security_update_check.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'app/security_update_check.go') diff --git a/app/security_update_check.go b/app/security_update_check.go index 1f1759fef..15bb81e5a 100644 --- a/app/security_update_check.go +++ b/app/security_update_check.go @@ -4,13 +4,14 @@ package app import ( + "fmt" "io/ioutil" "net/http" "net/url" "runtime" "strconv" - l4g "github.com/alecthomas/log4go" + "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" ) @@ -38,7 +39,7 @@ func (a *App) DoSecurityUpdateCheck() { currentTime := model.GetMillis() if (currentTime - lastSecurityTime) > SECURITY_UPDATE_PERIOD { - l4g.Debug(utils.T("mattermost.security_checks.debug")) + mlog.Debug("Checking for security update from Mattermost") v := url.Values{} @@ -75,7 +76,7 @@ func (a *App) DoSecurityUpdateCheck() { res, err := http.Get(SECURITY_URL + "/security?" + v.Encode()) if err != nil { - l4g.Error(utils.T("mattermost.security_info.error")) + mlog.Error("Failed to get security update information from Mattermost.") return } @@ -86,26 +87,26 @@ func (a *App) DoSecurityUpdateCheck() { if bulletin.AppliesToVersion == model.CurrentVersion { if props["SecurityBulletin_"+bulletin.Id] == "" { if results := <-a.Srv.Store.User().GetSystemAdminProfiles(); results.Err != nil { - l4g.Error(utils.T("mattermost.system_admins.error")) + mlog.Error("Failed to get system admins for security update information from Mattermost.") return } else { users := results.Data.(map[string]*model.User) resBody, err := http.Get(SECURITY_URL + "/bulletins/" + bulletin.Id) if err != nil { - l4g.Error(utils.T("mattermost.security_bulletin.error")) + mlog.Error("Failed to get security bulletin details") return } body, err := ioutil.ReadAll(resBody.Body) res.Body.Close() if err != nil || resBody.StatusCode != 200 { - l4g.Error(utils.T("mattermost.security_bulletin_read.error")) + mlog.Error("Failed to read security bulletin details") return } for _, user := range users { - l4g.Info(utils.T("mattermost.send_bulletin.info"), bulletin.Id, user.Email) + mlog.Info(fmt.Sprintf("Sending security bulletin for %v to %v", bulletin.Id, user.Email)) a.SendMail(user.Email, utils.T("mattermost.bulletin.subject"), string(body)) } } -- cgit v1.2.3-1-g7c22