diff options
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/account/create.go | 4 | ||||
-rw-r--r-- | internal/processing/account/delete.go | 2 | ||||
-rw-r--r-- | internal/processing/account/update.go | 4 | ||||
-rw-r--r-- | internal/processing/admin/createdomainblock.go | 7 | ||||
-rw-r--r-- | internal/processing/admin/mediarefetch.go | 6 | ||||
-rw-r--r-- | internal/processing/fromclientapi.go | 2 | ||||
-rw-r--r-- | internal/processing/fromfederator.go | 2 | ||||
-rw-r--r-- | internal/processing/media/getemoji.go | 2 | ||||
-rw-r--r-- | internal/processing/notification.go | 2 | ||||
-rw-r--r-- | internal/processing/search.go | 3 | ||||
-rw-r--r-- | internal/processing/statustimeline.go | 14 | ||||
-rw-r--r-- | internal/processing/streaming/openstream.go | 10 |
12 files changed, 30 insertions, 28 deletions
diff --git a/internal/processing/account/create.go b/internal/processing/account/create.go index 11d77a302..b0efccf7e 100644 --- a/internal/processing/account/create.go +++ b/internal/processing/account/create.go @@ -59,13 +59,13 @@ func (p *processor) Create(ctx context.Context, applicationToken oauth2.TokenInf reason = "" } - log.Trace("creating new username and account") + log.Trace(ctx, "creating new username and account") user, err := p.db.NewSignup(ctx, form.Username, text.SanitizePlaintext(reason), approvalRequired, form.Email, form.Password, form.IP, form.Locale, application.ID, false, "", false) if err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("error creating new signup in the database: %s", err)) } - log.Tracef("generating a token for user %s with account %s and application %s", user.ID, user.AccountID, application.ID) + log.Tracef(ctx, "generating a token for user %s with account %s and application %s", user.ID, user.AccountID, application.ID) accessToken, err := p.oauthServer.GenerateUserAccessToken(ctx, applicationToken, application.ClientSecret, user.ID) if err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("error creating new access token for user %s: %s", user.ID, err)) diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go index b06a7b960..32321e196 100644 --- a/internal/processing/account/delete.go +++ b/internal/processing/account/delete.go @@ -64,7 +64,7 @@ func (p *processor) Delete(ctx context.Context, account *gtsmodel.Account, origi }) } - l := log.WithFields(fields...) + l := log.WithContext(ctx).WithFields(fields...) l.Trace("beginning account delete process") // 1. Delete account's application(s), clients, and oauth tokens diff --git a/internal/processing/account/update.go b/internal/processing/account/update.go index dc4081915..675793800 100644 --- a/internal/processing/account/update.go +++ b/internal/processing/account/update.go @@ -97,7 +97,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form } account.AvatarMediaAttachmentID = avatarInfo.ID account.AvatarMediaAttachment = avatarInfo - log.Tracef("new avatar info for account %s is %+v", account.ID, avatarInfo) + log.Tracef(ctx, "new avatar info for account %s is %+v", account.ID, avatarInfo) } if form.Header != nil && form.Header.Size != 0 { @@ -107,7 +107,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form } account.HeaderMediaAttachmentID = headerInfo.ID account.HeaderMediaAttachment = headerInfo - log.Tracef("new header info for account %s is %+v", account.ID, headerInfo) + log.Tracef(ctx, "new header info for account %s is %+v", account.ID, headerInfo) } if form.Locked != nil { diff --git a/internal/processing/admin/createdomainblock.go b/internal/processing/admin/createdomainblock.go index 1c80ee78f..5c3542f79 100644 --- a/internal/processing/admin/createdomainblock.go +++ b/internal/processing/admin/createdomainblock.go @@ -89,9 +89,10 @@ func (p *processor) DomainBlockCreate(ctx context.Context, account *gtsmodel.Acc // 2. Delete the instance account for that instance if it exists. // 3. Select all accounts from this instance and pass them through the delete functionality of the processor. func (p *processor) initiateDomainBlockSideEffects(ctx context.Context, account *gtsmodel.Account, block *gtsmodel.DomainBlock) { - l := log.WithFields(kv.Fields{ - {"domain", block.Domain}, - }...) + l := log.WithContext(ctx). + WithFields(kv.Fields{ + {"domain", block.Domain}, + }...) l.Debug("processing domain block side effects") diff --git a/internal/processing/admin/mediarefetch.go b/internal/processing/admin/mediarefetch.go index 6bb068d58..a73580d98 100644 --- a/internal/processing/admin/mediarefetch.go +++ b/internal/processing/admin/mediarefetch.go @@ -35,12 +35,12 @@ func (p *processor) MediaRefetch(ctx context.Context, requestingAccount *gtsmode } go func() { - log.Info("starting emoji refetch") + log.Info(ctx, "starting emoji refetch") refetched, err := p.mediaManager.RefetchEmojis(context.Background(), domain, transport.DereferenceMedia) if err != nil { - log.Errorf("error refetching emojis: %s", err) + log.Errorf(ctx, "error refetching emojis: %s", err) } else { - log.Infof("refetched %d emojis from remote", refetched) + log.Infof(ctx, "refetched %d emojis from remote", refetched) } }() diff --git a/internal/processing/fromclientapi.go b/internal/processing/fromclientapi.go index 6035130e2..ef834a570 100644 --- a/internal/processing/fromclientapi.go +++ b/internal/processing/fromclientapi.go @@ -50,7 +50,7 @@ func (p *processor) ProcessFromClientAPI(ctx context.Context, clientMsg messages } // Log this federated message - l := log.WithFields(fields...) + l := log.WithContext(ctx).WithFields(fields...) l.Info("processing from client") switch clientMsg.APActivityType { diff --git a/internal/processing/fromfederator.go b/internal/processing/fromfederator.go index e37488794..7a3508840 100644 --- a/internal/processing/fromfederator.go +++ b/internal/processing/fromfederator.go @@ -59,7 +59,7 @@ func (p *processor) ProcessFromFederator(ctx context.Context, federatorMsg messa } // Log this federated message - l := log.WithFields(fields...) + l := log.WithContext(ctx).WithFields(fields...) l.Info("processing from federator") switch federatorMsg.APActivityType { diff --git a/internal/processing/media/getemoji.go b/internal/processing/media/getemoji.go index 592fc682f..4b1e76772 100644 --- a/internal/processing/media/getemoji.go +++ b/internal/processing/media/getemoji.go @@ -40,7 +40,7 @@ func (p *processor) GetCustomEmojis(ctx context.Context) ([]*apimodel.Emoji, gts for _, gtsEmoji := range emojis { apiEmoji, err := p.tc.EmojiToAPIEmoji(ctx, gtsEmoji) if err != nil { - log.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err) + log.Errorf(ctx, "error converting emoji with id %s: %s", gtsEmoji.ID, err) continue } apiEmojis = append(apiEmojis, &apiEmoji) diff --git a/internal/processing/notification.go b/internal/processing/notification.go index 47b5f07a9..b13ab0ca0 100644 --- a/internal/processing/notification.go +++ b/internal/processing/notification.go @@ -46,7 +46,7 @@ func (p *processor) NotificationsGet(ctx context.Context, authed *oauth.Auth, ex for i, n := range notifs { item, err := p.tc.NotificationToAPINotification(ctx, n) if err != nil { - log.Debugf("got an error converting a notification to api, will skip it: %s", err) + log.Debugf(ctx, "got an error converting a notification to api, will skip it: %s", err) continue } diff --git a/internal/processing/search.go b/internal/processing/search.go index 90e361cf7..44f38db12 100644 --- a/internal/processing/search.go +++ b/internal/processing/search.go @@ -57,7 +57,8 @@ func (p *processor) SearchGet(ctx context.Context, authed *oauth.Auth, search *a return nil, gtserror.NewErrorBadRequest(err, err.Error()) } - l := log.WithFields(kv.Fields{{"query", query}}...) + l := log.WithContext(ctx). + WithFields(kv.Fields{{"query", query}}...) searchResult := &apimodel.SearchResult{ Accounts: []apimodel.Account{}, diff --git a/internal/processing/statustimeline.go b/internal/processing/statustimeline.go index 447a2a000..45a1c4508 100644 --- a/internal/processing/statustimeline.go +++ b/internal/processing/statustimeline.go @@ -72,7 +72,7 @@ func StatusFilterFunction(database db.DB, filter visibility.Filter) timeline.Fil timelineable, err := filter.StatusHometimelineable(ctx, status, requestingAccount) if err != nil { - log.Warnf("error checking hometimelineability of status %s for account %s: %s", status.ID, timelineAccountID, err) + log.Warnf(ctx, "error checking hometimelineability of status %s for account %s: %s", status.ID, timelineAccountID, err) } return timelineable, nil // we don't return the error here because we want to just skip this item if something goes wrong @@ -257,7 +257,7 @@ func (p *processor) filterPublicStatuses(ctx context.Context, authed *oauth.Auth targetAccount := >smodel.Account{} if err := p.db.GetByID(ctx, s.AccountID, targetAccount); err != nil { if err == db.ErrNoEntries { - log.Debugf("filterPublicStatuses: skipping status %s because account %s can't be found in the db", s.ID, s.AccountID) + log.Debugf(ctx, "skipping status %s because account %s can't be found in the db", s.ID, s.AccountID) continue } return nil, gtserror.NewErrorInternalError(fmt.Errorf("filterPublicStatuses: error getting status author: %s", err)) @@ -265,7 +265,7 @@ func (p *processor) filterPublicStatuses(ctx context.Context, authed *oauth.Auth timelineable, err := p.filter.StatusPublictimelineable(ctx, s, authed.Account) if err != nil { - log.Debugf("filterPublicStatuses: skipping status %s because of an error checking status visibility: %s", s.ID, err) + log.Debugf(ctx, "skipping status %s because of an error checking status visibility: %s", s.ID, err) continue } if !timelineable { @@ -274,7 +274,7 @@ func (p *processor) filterPublicStatuses(ctx context.Context, authed *oauth.Auth apiStatus, err := p.tc.StatusToAPIStatus(ctx, s, authed.Account) if err != nil { - log.Debugf("filterPublicStatuses: skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err) + log.Debugf(ctx, "skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err) continue } @@ -290,7 +290,7 @@ func (p *processor) filterFavedStatuses(ctx context.Context, authed *oauth.Auth, targetAccount := >smodel.Account{} if err := p.db.GetByID(ctx, s.AccountID, targetAccount); err != nil { if err == db.ErrNoEntries { - log.Debugf("filterFavedStatuses: skipping status %s because account %s can't be found in the db", s.ID, s.AccountID) + log.Debugf(ctx, "skipping status %s because account %s can't be found in the db", s.ID, s.AccountID) continue } return nil, gtserror.NewErrorInternalError(fmt.Errorf("filterPublicStatuses: error getting status author: %s", err)) @@ -298,7 +298,7 @@ func (p *processor) filterFavedStatuses(ctx context.Context, authed *oauth.Auth, timelineable, err := p.filter.StatusVisible(ctx, s, authed.Account) if err != nil { - log.Debugf("filterFavedStatuses: skipping status %s because of an error checking status visibility: %s", s.ID, err) + log.Debugf(ctx, "skipping status %s because of an error checking status visibility: %s", s.ID, err) continue } if !timelineable { @@ -307,7 +307,7 @@ func (p *processor) filterFavedStatuses(ctx context.Context, authed *oauth.Auth, apiStatus, err := p.tc.StatusToAPIStatus(ctx, s, authed.Account) if err != nil { - log.Debugf("filterFavedStatuses: skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err) + log.Debugf(ctx, "skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err) continue } diff --git a/internal/processing/streaming/openstream.go b/internal/processing/streaming/openstream.go index 0ad5135fb..7913e6745 100644 --- a/internal/processing/streaming/openstream.go +++ b/internal/processing/streaming/openstream.go @@ -32,11 +32,11 @@ import ( ) func (p *processor) OpenStreamForAccount(ctx context.Context, account *gtsmodel.Account, streamTimeline string) (*stream.Stream, gtserror.WithCode) { - l := log.WithFields(kv.Fields{ - - {"account", account.ID}, - {"streamType", streamTimeline}, - }...) + l := log.WithContext(ctx). + WithFields(kv.Fields{ + {"account", account.ID}, + {"streamType", streamTimeline}, + }...) l.Debug("received open stream request") // each stream needs a unique ID so we know to close it |