diff options
author | 2023-02-17 12:02:29 +0100 | |
---|---|---|
committer | 2023-02-17 12:02:29 +0100 | |
commit | 68e6d08c768b789987a753d42f66caf73ce10ee1 (patch) | |
tree | 1c9eb6da6c326266d653de80684c3aec58922638 /internal/typeutils/internaltofrontend.go | |
parent | [bugfix] Set 'discoverable' properly on API accounts (#1511) (diff) | |
download | gotosocial-68e6d08c768b789987a753d42f66caf73ce10ee1.tar.xz |
[feature] Add a request ID and include it in logs (#1476)
This adds a lightweight form of tracing to GTS. Each incoming request is
assigned a Request ID which we then pass on and log in all our log
lines. Any function that gets called downstream from an HTTP handler
should now emit a requestID=value pair whenever it logs something.
Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 738155532..6e6bc381e 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -119,7 +119,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A if a.AvatarMediaAttachment == nil { avi, err := c.db.GetAttachmentByID(ctx, a.AvatarMediaAttachmentID) if err != nil { - log.Errorf("AccountToAPIAccountPublic: error getting Avatar with id %s: %s", a.AvatarMediaAttachmentID, err) + log.Errorf(ctx, "error getting Avatar with id %s: %s", a.AvatarMediaAttachmentID, err) } a.AvatarMediaAttachment = avi } @@ -136,7 +136,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A if a.HeaderMediaAttachment == nil { avi, err := c.db.GetAttachmentByID(ctx, a.HeaderMediaAttachmentID) if err != nil { - log.Errorf("AccountToAPIAccountPublic: error getting Header with id %s: %s", a.HeaderMediaAttachmentID, err) + log.Errorf(ctx, "error getting Header with id %s: %s", a.HeaderMediaAttachmentID, err) } a.HeaderMediaAttachment = avi } @@ -164,7 +164,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A // convert account gts model emojis to frontend api model emojis apiEmojis, err := c.convertEmojisToAPIEmojis(ctx, a.Emojis, a.EmojiIDs) if err != nil { - log.Errorf("error converting account emojis: %v", err) + log.Errorf(ctx, "error converting account emojis: %v", err) } var ( @@ -577,31 +577,31 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r // convert status gts model attachments to frontend api model attachments apiAttachments, err := c.convertAttachmentsToAPIAttachments(ctx, s.Attachments, s.AttachmentIDs) if err != nil { - log.Errorf("error converting status attachments: %v", err) + log.Errorf(ctx, "error converting status attachments: %v", err) } // convert status gts model mentions to frontend api model mentions apiMentions, err := c.convertMentionsToAPIMentions(ctx, s.Mentions, s.MentionIDs) if err != nil { - log.Errorf("error converting status mentions: %v", err) + log.Errorf(ctx, "error converting status mentions: %v", err) } // convert status gts model tags to frontend api model tags apiTags, err := c.convertTagsToAPITags(ctx, s.Tags, s.TagIDs) if err != nil { - log.Errorf("error converting status tags: %v", err) + log.Errorf(ctx, "error converting status tags: %v", err) } // convert status gts model emojis to frontend api model emojis apiEmojis, err := c.convertEmojisToAPIEmojis(ctx, s.Emojis, s.EmojiIDs) if err != nil { - log.Errorf("error converting status emojis: %v", err) + log.Errorf(ctx, "error converting status emojis: %v", err) } // Fetch status interaction flags for acccount interacts, err := c.interactionsWithStatusForAccount(ctx, s, requestingAccount) if err != nil { - log.Errorf("error getting interactions for status %s for account %s: %v", s.ID, requestingAccount.ID, err) + log.Errorf(ctx, "error getting interactions for status %s for account %s: %v", s.ID, requestingAccount.ID, err) // Ensure a non nil object interacts = &statusInteractions{} |