Reduce usage of mlog.Any (#25180)

This commit is contained in:
Ben Schumacher
2023-11-01 12:57:13 +01:00
committed by GitHub
parent 73fba481ed
commit 274adbf077
6 changed files with 12 additions and 8 deletions

View File

@@ -1318,7 +1318,7 @@ func (a *App) importAttachment(c request.CTX, data *imports.AttachmentImportData
oldHash := sha1.Sum(oldFileData)
if bytes.Equal(oldHash[:], newHash[:]) {
mlog.Info("Skipping uploading of file because name already exists", mlog.Any("file_name", name))
mlog.Info("Skipping uploading of file because name already exists", mlog.String("file_name", name))
return oldFile, nil
}
}
@@ -1645,7 +1645,7 @@ func (a *App) uploadAttachments(c request.CTX, attachments *[]imports.Attachment
func (a *App) updateFileInfoWithPostId(post *model.Post) {
for _, fileID := range post.FileIds {
if err := a.Srv().Store().FileInfo().AttachToPost(fileID, post.Id, post.ChannelId, post.UserId); err != nil {
mlog.Error("Error attaching files to post.", mlog.String("post_id", post.Id), mlog.Any("post_file_ids", post.FileIds), mlog.Err(err))
mlog.Error("Error attaching files to post.", mlog.String("post_id", post.Id), mlog.Array("post_file_ids", post.FileIds), mlog.Err(err))
}
}
}

View File

@@ -511,7 +511,7 @@ func (wc *WebConn) writePump() {
case <-authTicker.C:
if wc.GetSessionToken() == "" {
mlog.Debug("websocket.authTicker: did not authenticate", mlog.Any("ip_address", wc.WebSocket.RemoteAddr()))
mlog.Debug("websocket.authTicker: did not authenticate", mlog.Stringer("ip_address", wc.WebSocket.RemoteAddr()))
return
}
authTicker.Stop()

View File

@@ -362,7 +362,7 @@ func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel
if len(post.FileIds) > 0 {
if err = a.attachFilesToPost(post); err != nil {
c.Logger().Warn("Encountered error attaching files to post", mlog.String("post_id", post.Id), mlog.Any("file_ids", post.FileIds), mlog.Err(err))
c.Logger().Warn("Encountered error attaching files to post", mlog.String("post_id", post.Id), mlog.Array("file_ids", post.FileIds), mlog.Err(err))
}
if a.Metrics() != nil {

View File

@@ -216,7 +216,7 @@ func (a *App) SyncSyncableRoles(syncableID string, syncableType model.GroupSynca
a.Log().Info(
fmt.Sprintf("Permitted admins for %s", syncableType),
mlog.String(strings.ToLower(fmt.Sprintf("%s_id", syncableType)), syncableID),
mlog.Any("permitted_admins", permittedAdmins),
mlog.Array("permitted_admins", permittedAdmins),
)
switch syncableType {

View File

@@ -428,7 +428,7 @@ func (scs *Service) sendUserSyncData(sd *syncData) error {
scs.server.Log().Log(mlog.LvlSharedChannelServiceError, "Response indicates error for user(s) sync",
mlog.String("channel_id", sd.task.channelID),
mlog.String("remote_id", sd.rc.RemoteId),
mlog.Any("users", syncResp.UserErrors),
mlog.Array("users", syncResp.UserErrors),
)
}
})
@@ -460,7 +460,7 @@ func (scs *Service) sendPostSyncData(sd *syncData) error {
scs.server.Log().Log(mlog.LvlSharedChannelServiceError, "Response indicates error for post(s) sync",
mlog.String("channel_id", sd.task.channelID),
mlog.String("remote_id", sd.rc.RemoteId),
mlog.Any("posts", syncResp.PostErrors),
mlog.Array("posts", syncResp.PostErrors),
)
for _, postID := range syncResp.PostErrors {
@@ -481,7 +481,7 @@ func (scs *Service) sendReactionSyncData(sd *syncData) error {
scs.server.Log().Log(mlog.LvlSharedChannelServiceError, "Response indicates error for reactions(s) sync",
mlog.String("channel_id", sd.task.channelID),
mlog.String("remote_id", sd.rc.RemoteId),
mlog.Any("reaction_posts", syncResp.ReactionErrors),
mlog.Array("reaction_posts", syncResp.ReactionErrors),
)
}
})

View File

@@ -62,6 +62,10 @@ func (group *Group) Auditable() map[string]interface{} {
}
}
func (group *Group) LogClone() any {
return group.Auditable()
}
type GroupWithUserIds struct {
Group
UserIds []string `json:"user_ids"`