[MM-55480] Update logr to v2.0.21 (#25431)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7848ea8e19
Коммит
e99ded1635
@@ -703,7 +703,7 @@ func setServerBusy(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
audit.AddEventParameter(auditRec, "seconds", i)
|
||||
|
||||
c.App.Srv().Platform().Busy.Set(time.Second * time.Duration(i))
|
||||
c.Logger.Warn("server busy state activated - non-critical services disabled", mlog.Int64("seconds", i))
|
||||
c.Logger.Warn("server busy state activated - non-critical services disabled", mlog.Int("seconds", i))
|
||||
|
||||
auditRec.Success()
|
||||
ReturnStatusOK(w)
|
||||
|
||||
@@ -120,7 +120,7 @@ func (s *Server) configureAudit(adt *audit.Audit, bAllowAdvancedLogging bool) er
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid config source for audit, %w", err)
|
||||
}
|
||||
mlog.Debug("Loaded audit configuration", mlog.String("source", string(dsn)))
|
||||
mlog.Debug("Loaded audit configuration", mlog.String("source", dsn))
|
||||
} else {
|
||||
s.Log().Debug("Advanced logging config not provided for audit")
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ func (a *App) bulkImportWorker(c request.CTX, dryRun bool, wg *sync.WaitGroup, l
|
||||
c.Logger().Info("Started new bulk import worker", mlog.String("bulk_import_worker_id", workerID))
|
||||
defer func() {
|
||||
wg.Done()
|
||||
c.Logger().Info("Bulk import worker finished", mlog.String("bulk_import_worker_id", workerID), mlog.Uint64("processed_lines", processedLines))
|
||||
c.Logger().Info("Bulk import worker finished", mlog.String("bulk_import_worker_id", workerID), mlog.Uint("processed_lines", processedLines))
|
||||
}()
|
||||
|
||||
postLines := []imports.LineImportWorkerData{}
|
||||
@@ -155,7 +155,7 @@ func (a *App) bulkImportWorker(c request.CTX, dryRun bool, wg *sync.WaitGroup, l
|
||||
|
||||
processedLines++
|
||||
if processedLines%statusUpdateAfterLines == 0 {
|
||||
c.Logger().Info("Worker progress", mlog.String("bulk_import_worker_id", workerID), mlog.Uint64("processed_lines", processedLines))
|
||||
c.Logger().Info("Worker progress", mlog.String("bulk_import_worker_id", workerID), mlog.Uint("processed_lines", processedLines))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/logr/v2"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
@@ -31,7 +29,7 @@ import (
|
||||
// These functions import data directly into the database. Security and permission checks are bypassed but validity is
|
||||
// still enforced.
|
||||
func (a *App) importScheme(rctx request.CTX, data *imports.SchemeImportData, dryRun bool) *model.AppError {
|
||||
var fields []logr.Field
|
||||
var fields []mlog.Field
|
||||
if data != nil && data.Name != nil {
|
||||
fields = append(fields, mlog.String("schema_name", *data.Name))
|
||||
}
|
||||
@@ -121,7 +119,7 @@ func (a *App) importScheme(rctx request.CTX, data *imports.SchemeImportData, dry
|
||||
}
|
||||
|
||||
func (a *App) importRole(rctx request.CTX, data *imports.RoleImportData, dryRun bool, isSchemeRole bool) *model.AppError {
|
||||
var fields []logr.Field
|
||||
var fields []mlog.Field
|
||||
if data != nil && data.Name != nil {
|
||||
fields = append(fields, mlog.String("role_name", *data.Name))
|
||||
}
|
||||
@@ -176,7 +174,7 @@ func (a *App) importRole(rctx request.CTX, data *imports.RoleImportData, dryRun
|
||||
}
|
||||
|
||||
func (a *App) importTeam(rctx request.CTX, data *imports.TeamImportData, dryRun bool) *model.AppError {
|
||||
var fields []logr.Field
|
||||
var fields []mlog.Field
|
||||
if data != nil && data.Name != nil {
|
||||
fields = append(fields, mlog.String("team_name", *data.Name))
|
||||
}
|
||||
@@ -252,7 +250,7 @@ func (a *App) importTeam(rctx request.CTX, data *imports.TeamImportData, dryRun
|
||||
}
|
||||
|
||||
func (a *App) importChannel(rctx request.CTX, data *imports.ChannelImportData, dryRun bool) *model.AppError {
|
||||
var fields []logr.Field
|
||||
var fields []mlog.Field
|
||||
if data != nil && data.Name != nil {
|
||||
fields = append(fields, mlog.String("channel_name", *data.Name))
|
||||
}
|
||||
@@ -332,7 +330,7 @@ func (a *App) importChannel(rctx request.CTX, data *imports.ChannelImportData, d
|
||||
}
|
||||
|
||||
func (a *App) importUser(rctx request.CTX, data *imports.UserImportData, dryRun bool) *model.AppError {
|
||||
var fields []logr.Field
|
||||
var fields []mlog.Field
|
||||
if data != nil && data.Username != nil {
|
||||
fields = append(fields, mlog.String("user_name", *data.Username))
|
||||
}
|
||||
@@ -1205,7 +1203,7 @@ func (a *App) importReplies(rctx request.CTX, data []imports.ReplyImportData, po
|
||||
reply.Message = *replyData.Message
|
||||
reply.CreateAt = *replyData.CreateAt
|
||||
if reply.CreateAt < post.CreateAt {
|
||||
rctx.Logger().Warn("Reply CreateAt is before parent post CreateAt, setting it to parent post CreateAt", mlog.Int64("reply_create_at", reply.CreateAt), mlog.Int64("parent_create_at", post.CreateAt))
|
||||
rctx.Logger().Warn("Reply CreateAt is before parent post CreateAt, setting it to parent post CreateAt", mlog.Int("reply_create_at", reply.CreateAt), mlog.Int("parent_create_at", post.CreateAt))
|
||||
reply.CreateAt = post.CreateAt
|
||||
}
|
||||
if replyData.Type != nil {
|
||||
@@ -1274,7 +1272,7 @@ func (a *App) importAttachment(rctx request.CTX, data *imports.AttachmentImportD
|
||||
name = data.Data.Name
|
||||
file = zipFile.(io.Reader)
|
||||
|
||||
rctx.Logger().Info("Preparing file upload from ZIP", mlog.String("file_name", name), mlog.Uint64("file_size", data.Data.UncompressedSize64))
|
||||
rctx.Logger().Info("Preparing file upload from ZIP", mlog.String("file_name", name), mlog.Uint("file_size", data.Data.UncompressedSize64))
|
||||
} else {
|
||||
realFile, err := os.Open(*data.Path)
|
||||
if err != nil {
|
||||
@@ -1284,9 +1282,9 @@ func (a *App) importAttachment(rctx request.CTX, data *imports.AttachmentImportD
|
||||
name = realFile.Name()
|
||||
file = realFile
|
||||
|
||||
fields := []logr.Field{mlog.String("file_name", name)}
|
||||
fields := []mlog.Field{mlog.String("file_name", name)}
|
||||
if info, err := realFile.Stat(); err != nil {
|
||||
fields = append(fields, mlog.Int64("file_size", info.Size()))
|
||||
fields = append(fields, mlog.Int("file_size", info.Size()))
|
||||
}
|
||||
rctx.Logger().Info("Preparing file upload from file system", fields...)
|
||||
}
|
||||
@@ -1928,7 +1926,7 @@ func (a *App) importMultipleDirectPostLines(rctx request.CTX, lines []imports.Li
|
||||
}
|
||||
|
||||
func (a *App) importEmoji(rctx request.CTX, data *imports.EmojiImportData, dryRun bool) *model.AppError {
|
||||
var fields []logr.Field
|
||||
var fields []mlog.Field
|
||||
if data != nil && data.Name != nil {
|
||||
fields = append(fields, mlog.String("emoji_name", *data.Name))
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ func ValidateReplyImportData(data *ReplyImportData, parentCreateAt int64, maxPos
|
||||
} else if *data.CreateAt == 0 {
|
||||
return model.NewAppError("BulkImport", "app.import.validate_reply_import_data.create_at_zero.error", nil, "", http.StatusBadRequest)
|
||||
} else if *data.CreateAt < parentCreateAt {
|
||||
mlog.Warn("Reply CreateAt is before parent post CreateAt", mlog.Int64("reply_create_at", *data.CreateAt), mlog.Int64("parent_create_at", parentCreateAt))
|
||||
mlog.Warn("Reply CreateAt is before parent post CreateAt", mlog.Int("reply_create_at", *data.CreateAt), mlog.Int("parent_create_at", parentCreateAt))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -377,11 +377,11 @@ func (hub *PushNotificationsHub) start(c request.CTX) {
|
||||
case notificationTypeUpdateBadge:
|
||||
err = hub.app.updateMobileAppBadgeSync(c, notification.userID)
|
||||
default:
|
||||
mlog.Debug("Invalid notification type", mlog.String("notification_type", string(notification.notificationType)))
|
||||
mlog.Debug("Invalid notification type", mlog.String("notification_type", notification.notificationType))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
mlog.Error("Unable to send push notification", mlog.String("notification_type", string(notification.notificationType)), mlog.Err(err))
|
||||
mlog.Error("Unable to send push notification", mlog.String("notification_type", notification.notificationType), mlog.Err(err))
|
||||
}
|
||||
}(notification)
|
||||
case <-hub.stopChan:
|
||||
@@ -473,7 +473,7 @@ func (a *App) SendAckToPushProxy(ack *model.PushNotificationAck) error {
|
||||
mlog.String("ackId", ack.Id),
|
||||
mlog.String("type", ack.NotificationType),
|
||||
mlog.String("deviceType", ack.ClientPlatform),
|
||||
mlog.Int64("receivedAt", ack.ClientReceivedAt),
|
||||
mlog.Int("receivedAt", ack.ClientReceivedAt),
|
||||
mlog.String("status", model.PushReceived),
|
||||
)
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ func (ps *PlatformService) clusterBusyStateChgHandler(msg *model.ClusterMessage)
|
||||
|
||||
ps.Busy.ClusterEventChanged(&sbs)
|
||||
if sbs.Busy {
|
||||
ps.logger.Warn("server busy state activated via cluster event - non-critical services disabled", mlog.Int64("expires_sec", sbs.Expires))
|
||||
ps.logger.Warn("server busy state activated via cluster event - non-critical services disabled", mlog.Int("expires_sec", sbs.Expires))
|
||||
} else {
|
||||
ps.logger.Info("server busy state cleared via cluster event - non-critical services enabled")
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func (ps *PlatformService) ConfigureLogger(name string, logger *mlog.Logger, log
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid config source for %s, %w", name, err)
|
||||
}
|
||||
ps.logger.Info("Loaded configuration for "+name, mlog.String("source", string(dsn)))
|
||||
ps.logger.Info("Loaded configuration for "+name, mlog.String("source", dsn))
|
||||
} else {
|
||||
ps.logger.Debug("Advanced logging config not provided for " + name)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func (ps *PlatformService) updateFeatureFlagValuesFromManagement() {
|
||||
newFlags := ps.featureFlagSynchronizer.UpdateFeatureFlagValues(oldFlags)
|
||||
oldFlagsBytes, _ := json.Marshal(oldFlags)
|
||||
newFlagsBytes, _ := json.Marshal(newFlags)
|
||||
ps.logger.Debug("Checking feature flags from management service", mlog.String("old_flags", string(oldFlagsBytes)), mlog.String("new_flags", string(newFlagsBytes)))
|
||||
ps.logger.Debug("Checking feature flags from management service", mlog.String("old_flags", oldFlagsBytes), mlog.String("new_flags", newFlagsBytes))
|
||||
if oldFlags != newFlags {
|
||||
ps.logger.Debug("Feature flag change detected, updating config")
|
||||
*newCfg.FeatureFlags = newFlags
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/logr/v2"
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/v8/config"
|
||||
@@ -32,7 +31,10 @@ func (ps *PlatformService) initLogging() error {
|
||||
// create the app logger if needed
|
||||
if ps.logger == nil {
|
||||
var err error
|
||||
ps.logger, err = mlog.NewLogger(logr.MaxFieldLen(*ps.Config().LogSettings.MaxFieldSize))
|
||||
ps.logger, err = mlog.NewLogger(
|
||||
mlog.MaxFieldLen(*ps.Config().LogSettings.MaxFieldSize),
|
||||
mlog.StackFilter("log"),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func (ps *PlatformService) SharedChannelSyncHandler(event *model.WebSocketEvent)
|
||||
if err != nil {
|
||||
mlog.Warn(
|
||||
err.Error(),
|
||||
mlog.String("event", string(event.EventType())),
|
||||
mlog.String("event", event.EventType()),
|
||||
mlog.String("action", "content_sync"),
|
||||
)
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func (ps *PlatformService) SharedChannelSyncHandler(event *model.WebSocketEvent)
|
||||
if err != nil {
|
||||
mlog.Warn(
|
||||
err.Error(),
|
||||
mlog.String("event", string(event.EventType())),
|
||||
mlog.String("event", event.EventType()),
|
||||
mlog.String("action", "invitation"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ func (wc *WebConn) writePump() {
|
||||
logData := []mlog.Field{
|
||||
mlog.String("user_id", wc.UserId),
|
||||
mlog.String("conn_id", wc.GetConnectionID()),
|
||||
mlog.String("type", string(msg.EventType())),
|
||||
mlog.String("type", msg.EventType()),
|
||||
mlog.Int("size", buf.Len()),
|
||||
}
|
||||
if evtOk {
|
||||
@@ -735,7 +735,7 @@ func (wc *WebConn) ShouldSendEvent(msg *model.WebSocketEvent) bool {
|
||||
"websocket.slow: dropping message",
|
||||
mlog.String("user_id", wc.UserId),
|
||||
mlog.String("conn_id", wc.GetConnectionID()),
|
||||
mlog.String("type", string(msg.EventType())),
|
||||
mlog.String("type", msg.EventType()),
|
||||
)
|
||||
// Reset timer to now.
|
||||
wc.lastLogTimeSlow = time.Now()
|
||||
|
||||
@@ -96,7 +96,7 @@ func returnWebSocketError(ps *PlatformService, conn *WebConn, r *model.WebSocket
|
||||
}
|
||||
logF(
|
||||
"websocket routing error.",
|
||||
mlog.Int64("seq", r.Seq),
|
||||
mlog.Int("seq", r.Seq),
|
||||
mlog.String("user_id", conn.UserId),
|
||||
mlog.String("system_message", err.SystemMessage(i18n.T)),
|
||||
mlog.Err(err),
|
||||
|
||||
@@ -280,7 +280,7 @@ func (a *App) ExtendSessionExpiryIfNeeded(rctx request.CTX, session *model.Sessi
|
||||
}
|
||||
|
||||
mlog.Debug("Session extended", mlog.String("user_id", session.UserId), mlog.String("session_id", session.Id),
|
||||
mlog.Int64("newExpiry", newExpiry), mlog.Int64("session_length", sessionLength))
|
||||
mlog.Int("newExpiry", newExpiry), mlog.Int("session_length", sessionLength))
|
||||
|
||||
auditRec.Success()
|
||||
auditRec.AddEventResultState(session)
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/logr/v2"
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/i18n"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/app"
|
||||
"github.com/mattermost/mattermost/server/v8/platform/shared/filestore"
|
||||
@@ -86,7 +86,7 @@ func (*ExportLinkProvider) DoCommand(a *app.App, c request.CTX, args *model.Comm
|
||||
}
|
||||
t, err := b.FileModTime(f)
|
||||
if err != nil {
|
||||
a.Log().Warn("Failed to get file mod time", logr.String("file", f), logr.Err(err))
|
||||
a.Log().Warn("Failed to get file mod time", mlog.String("file", f), mlog.Err(err))
|
||||
continue
|
||||
}
|
||||
if t.After(latestFound) {
|
||||
|
||||
@@ -83,10 +83,10 @@ func (s SearchFileInfoStore) deleteFileIndexBatch(endTime, limit int64) {
|
||||
if engine.IsIndexingEnabled() {
|
||||
runIndexFn(engine, func(engineCopy searchengine.SearchEngineInterface) {
|
||||
if err := engineCopy.DeleteFilesBatch(endTime, limit); err != nil {
|
||||
mlog.Error("Encountered error deleting a batch of files", mlog.Int64("limit", limit), mlog.Int64("end_time", endTime), mlog.String("search_engine", engineCopy.GetName()), mlog.Err(err))
|
||||
mlog.Error("Encountered error deleting a batch of files", mlog.Int("limit", limit), mlog.Int("end_time", endTime), mlog.String("search_engine", engineCopy.GetName()), mlog.Err(err))
|
||||
return
|
||||
}
|
||||
mlog.Debug("Removed batch of files from the index in search engine", mlog.String("search_engine", engineCopy.GetName()), mlog.Int64("end_time", endTime), mlog.Int64("limit", limit))
|
||||
mlog.Debug("Removed batch of files from the index in search engine", mlog.String("search_engine", engineCopy.GetName()), mlog.Int("end_time", endTime), mlog.Int("limit", limit))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ func (s *SqlDraftStore) determineMaxDraftSize() int {
|
||||
// Assume a worst-case representation of four bytes per rune.
|
||||
maxDraftSize := int(maxDraftSizeBytes) / 4
|
||||
|
||||
mlog.Info("Draft.Message has size restrictions", mlog.Int("max_characters", maxDraftSize), mlog.Int32("max_bytes", maxDraftSizeBytes))
|
||||
mlog.Info("Draft.Message has size restrictions", mlog.Int("max_characters", maxDraftSize), mlog.Int("max_bytes", maxDraftSizeBytes))
|
||||
|
||||
return maxDraftSize
|
||||
}
|
||||
|
||||
@@ -2548,7 +2548,7 @@ func (s *SqlPostStore) determineMaxPostSize() int {
|
||||
maxPostSize = model.PostMessageMaxRunesV1
|
||||
}
|
||||
|
||||
mlog.Info("Post.Message has size restrictions", mlog.Int("max_characters", maxPostSize), mlog.Int32("max_bytes", maxPostSizeBytes))
|
||||
mlog.Info("Post.Message has size restrictions", mlog.Int("max_characters", maxPostSize), mlog.Int("max_bytes", maxPostSizeBytes))
|
||||
|
||||
return maxPostSize
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
fields = append(fields, mlog.NamedErr("encoding_err", err))
|
||||
} else {
|
||||
fields = append(fields, mlog.String("payload", string(payload)))
|
||||
fields = append(fields, mlog.String("payload", payload))
|
||||
}
|
||||
|
||||
mlog.Debug("Incoming webhook received", fields...)
|
||||
|
||||
@@ -36,7 +36,7 @@ func (wh webSocketHandler) ServeWebSocket(conn *platform.WebConn, r *model.WebSo
|
||||
mlog.Error(
|
||||
"websocket session error",
|
||||
mlog.String("action", r.Action),
|
||||
mlog.Int64("seq", r.Seq),
|
||||
mlog.Int("seq", r.Seq),
|
||||
mlog.String("user_id", conn.UserId),
|
||||
mlog.String("error_message", sessionErr.SystemMessage(i18n.T)),
|
||||
mlog.Err(sessionErr),
|
||||
@@ -58,7 +58,7 @@ func (wh webSocketHandler) ServeWebSocket(conn *platform.WebConn, r *model.WebSo
|
||||
mlog.Error(
|
||||
"websocket request handling error",
|
||||
mlog.String("action", r.Action),
|
||||
mlog.Int64("seq", r.Seq),
|
||||
mlog.Int("seq", r.Seq),
|
||||
mlog.String("user_id", conn.UserId),
|
||||
mlog.String("error_message", err.SystemMessage(i18n.T)),
|
||||
mlog.Err(err),
|
||||
|
||||
Ссылка в новой задаче
Block a user