mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Add context to post reminder error logs (#26633)
Previous log lines just had generic errors which made things difficult to debug because if a system bot is disabled, it's hard to know whether the error is coming while trying to send post reminders or from some other part of the system. ```release-note NONE ```
This commit is contained in:
parent
c7cb1bc400
commit
fc8e537288
@ -2194,9 +2194,10 @@ func (a *App) SetPostReminder(postID, userID string, targetTime int64) *model.Ap
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CheckPostReminders(rctx request.CTX) {
|
func (a *App) CheckPostReminders(rctx request.CTX) {
|
||||||
|
rctx = rctx.WithLogger(rctx.Logger().With(mlog.String("component", "post_reminders")))
|
||||||
systemBot, appErr := a.GetSystemBot(rctx)
|
systemBot, appErr := a.GetSystemBot(rctx)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
mlog.Error("Failed to get system bot", mlog.Err(appErr))
|
rctx.Logger().Error("Failed to get system bot", mlog.Err(appErr))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2207,7 +2208,7 @@ func (a *App) CheckPostReminders(rctx request.CTX) {
|
|||||||
// MM-45595.
|
// MM-45595.
|
||||||
reminders, err := a.Srv().Store().Post().GetPostReminders(time.Now().UTC().Unix())
|
reminders, err := a.Srv().Store().Post().GetPostReminders(time.Now().UTC().Unix())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mlog.Error("Failed to get post reminders", mlog.Err(err))
|
rctx.Logger().Error("Failed to get post reminders", mlog.Err(err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2225,14 +2226,14 @@ func (a *App) CheckPostReminders(rctx request.CTX) {
|
|||||||
for userID, postIDs := range groupedReminders {
|
for userID, postIDs := range groupedReminders {
|
||||||
ch, appErr := a.GetOrCreateDirectChannel(request.EmptyContext(a.Log()), userID, systemBot.UserId)
|
ch, appErr := a.GetOrCreateDirectChannel(request.EmptyContext(a.Log()), userID, systemBot.UserId)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
mlog.Error("Failed to get direct channel", mlog.Err(appErr))
|
rctx.Logger().Error("Failed to get direct channel", mlog.Err(appErr))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, postID := range postIDs {
|
for _, postID := range postIDs {
|
||||||
metadata, err := a.Srv().Store().Post().GetPostReminderMetadata(postID)
|
metadata, err := a.Srv().Store().Post().GetPostReminderMetadata(postID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mlog.Error("Failed to get post reminder metadata", mlog.Err(err), mlog.String("post_id", postID))
|
rctx.Logger().Error("Failed to get post reminder metadata", mlog.Err(err), mlog.String("post_id", postID))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2255,7 +2256,7 @@ func (a *App) CheckPostReminders(rctx request.CTX) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := a.CreatePost(request.EmptyContext(a.Log()), dm, ch, false, true); err != nil {
|
if _, err := a.CreatePost(request.EmptyContext(a.Log()), dm, ch, false, true); err != nil {
|
||||||
mlog.Error("Failed to post reminder message", mlog.Err(err))
|
rctx.Logger().Error("Failed to post reminder message", mlog.Err(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user