Converting to structured logging the file app/notification_pus… (#12126)

Этот коммит содержится в:
Nikhil Ranjan
2019-09-24 15:10:47 +00:00
коммит произвёл Ben Schumacher
родитель 7464449478
Коммит 7ba491ac2d

Просмотреть файл

@@ -4,7 +4,6 @@
package app package app
import ( import (
"fmt"
"hash/fnv" "hash/fnv"
"net/http" "net/http"
"strings" "strings"
@@ -174,7 +173,7 @@ func (a *App) getPushNotificationMessage(postMessage string, explicitMention, ch
func (a *App) ClearPushNotificationSync(currentSessionId, userId, channelId string) { func (a *App) ClearPushNotificationSync(currentSessionId, userId, channelId string) {
sessions, err := a.getMobileAppSessions(userId) sessions, err := a.getMobileAppSessions(userId)
if err != nil { if err != nil {
mlog.Error(err.Error()) mlog.Error("error getting mobile app sessions", mlog.Err(err))
return return
} }
@@ -187,7 +186,7 @@ func (a *App) ClearPushNotificationSync(currentSessionId, userId, channelId stri
if unreadCount, err := a.Srv.Store.User().GetUnreadCount(userId); err != nil { if unreadCount, err := a.Srv.Store.User().GetUnreadCount(userId); err != nil {
msg.Badge = 0 msg.Badge = 0
mlog.Error(fmt.Sprint("We could not get the unread message count for the user", userId, err), mlog.String("user_id", userId)) mlog.Error("We could not get the unread message count for", mlog.String("user_id", userId), mlog.Err(err))
} else { } else {
msg.Badge = int(unreadCount) msg.Badge = int(unreadCount)
} }
@@ -267,7 +266,7 @@ func (a *App) pushNotificationWorker(notifications chan PushNotification) {
notification.replyToThreadType, notification.replyToThreadType,
) )
default: default:
mlog.Error(fmt.Sprintf("Invalid notification type %v", notification.notificationType)) mlog.Error("Invalid notification type", mlog.String("notification_type", string(notification.notificationType)))
} }
} }
} }
@@ -446,14 +445,14 @@ func (a *App) BuildPushNotificationMessage(post *model.Post, user *model.User, c
if user.NotifyProps["push"] == "all" { if user.NotifyProps["push"] == "all" {
if unreadCount, err := a.Srv.Store.User().GetAnyUnreadPostCountForChannel(user.Id, channel.Id); err != nil { if unreadCount, err := a.Srv.Store.User().GetAnyUnreadPostCountForChannel(user.Id, channel.Id); err != nil {
msg.Badge = 1 msg.Badge = 1
mlog.Error(fmt.Sprint("We could not get the unread message count for the user", user.Id, err), mlog.String("user_id", user.Id)) mlog.Error("We could not get the unread message count for the user", mlog.String("user_id", user.Id), mlog.Err(err))
} else { } else {
msg.Badge = int(unreadCount) msg.Badge = int(unreadCount)
} }
} else { } else {
if unreadCount, err := a.Srv.Store.User().GetUnreadCount(user.Id); err != nil { if unreadCount, err := a.Srv.Store.User().GetUnreadCount(user.Id); err != nil {
msg.Badge = 1 msg.Badge = 1
mlog.Error(fmt.Sprint("We could not get the unread message count for the user", user.Id, err), mlog.String("user_id", user.Id)) mlog.Error("We could not get the unread message count for the user", mlog.String("user_id", user.Id), mlog.Err(err))
} else { } else {
msg.Badge = int(unreadCount) msg.Badge = int(unreadCount)
} }