diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-04-27 12:49:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 12:49:45 -0700 |
commit | 686c2fbab7607d42183ae685a27ea3d7dce8c3f6 (patch) | |
tree | 53ed73cada57bc43f342ac10e2f842cddb095218 /store/sqlstore/post_store.go | |
parent | 2acbc77d78456d7ba76ceb687b18985d7d92f814 (diff) | |
download | chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.tar.gz chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.tar.bz2 chat-686c2fbab7607d42183ae685a27ea3d7dce8c3f6.zip |
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.
Diffstat (limited to 'store/sqlstore/post_store.go')
-rw-r--r-- | store/sqlstore/post_store.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/store/sqlstore/post_store.go b/store/sqlstore/post_store.go index dc7248057..75154791c 100644 --- a/store/sqlstore/post_store.go +++ b/store/sqlstore/post_store.go @@ -12,8 +12,8 @@ import ( "strings" "sync" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/einterfaces" + "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/store" "github.com/mattermost/mattermost-server/utils" @@ -947,7 +947,7 @@ func (s *SqlPostStore) Search(teamId string, userId string, params *model.Search _, err := s.GetSearchReplica().Select(&posts, searchQuery, queryParams) if err != nil { - l4g.Warn(utils.T("store.sql_post.search.warn"), err.Error()) + mlog.Warn(fmt.Sprintf("Query error searching posts: %v", err.Error())) // Don't return the error to the caller as it is of no use to the user. Instead return an empty set of search results. } else { for _, p := range posts { @@ -1147,7 +1147,7 @@ func (s *SqlPostStore) GetPostsByIds(postIds []string) store.StoreChannel { _, err := s.GetReplica().Select(&posts, query, params) if err != nil { - l4g.Error(err) + mlog.Error(fmt.Sprint(err)) result.Err = model.NewAppError("SqlPostStore.GetPostsByIds", "store.sql_post.get_posts_by_ids.app_error", nil, "", http.StatusInternalServerError) } else { result.Data = posts @@ -1247,7 +1247,7 @@ func (s *SqlPostStore) determineMaxPostSize() int { table_name = 'posts' AND column_name = 'message' `); err != nil { - l4g.Error(utils.T("store.sql_post.query_max_post_size.error") + err.Error()) + mlog.Error(utils.T("store.sql_post.query_max_post_size.error") + err.Error()) } } else if s.DriverName() == model.DATABASE_DRIVER_MYSQL { // The Post.Message column in MySQL has historically been TEXT, with a maximum @@ -1263,10 +1263,10 @@ func (s *SqlPostStore) determineMaxPostSize() int { AND column_name = 'Message' LIMIT 0, 1 `); err != nil { - l4g.Error(utils.T("store.sql_post.query_max_post_size.error") + err.Error()) + mlog.Error(utils.T("store.sql_post.query_max_post_size.error") + err.Error()) } } else { - l4g.Warn(utils.T("store.sql_post.query_max_post_size.unrecognized_driver")) + mlog.Warn("No implementation found to determine the maximum supported post size") } // Assume a worst-case representation of four bytes per rune. @@ -1279,7 +1279,7 @@ func (s *SqlPostStore) determineMaxPostSize() int { maxPostSize = model.POST_MESSAGE_MAX_RUNES_V1 } - l4g.Info(utils.T("store.sql_post.query_max_post_size.max_post_size_bytes"), maxPostSize, maxPostSizeBytes) + mlog.Info(fmt.Sprintf("Post.Message supports at most %d characters (%d bytes)", maxPostSize, maxPostSizeBytes)) return maxPostSize } |