From 098dbe6ff4f59652181c8e0e3873fbfcf0e65ea3 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Tue, 19 Jul 2022 09:47:55 +0100 Subject: [chore] use our own logging implementation (#716) * first commit Signed-off-by: kim * replace logging with our own log library Signed-off-by: kim * fix imports Signed-off-by: kim * fix log imports Signed-off-by: kim * add license text Signed-off-by: kim * fix package import cycle between config and log package Signed-off-by: kim * fix empty kv.Fields{} being passed to WithFields() Signed-off-by: kim * fix uses of log.WithFields() with whitespace issues and empty slices Signed-off-by: kim * *linter related grumbling* Signed-off-by: kim * gofmt the codebase! also fix more log.WithFields() formatting issues Signed-off-by: kim * update testrig code to match new changes Signed-off-by: kim * fix error wrapping in non fmt.Errorf function Signed-off-by: kim * add benchmarking of log.Caller() vs non-cached Signed-off-by: kim * fix syslog tests, add standard build tags to test runner to ensure consistency Signed-off-by: kim * make syslog tests more robust Signed-off-by: kim * fix caller depth arithmatic (is that how you spell it?) Signed-off-by: kim * update to use unkeyed fields in kv.Field{} instances Signed-off-by: kim * update go-kv library Signed-off-by: kim * update libraries list Signed-off-by: kim * fuck you linter get nerfed Signed-off-by: kim Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com> --- internal/typeutils/internaltofrontend.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'internal/typeutils/internaltofrontend.go') diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 138b85553..1ac49688a 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -23,12 +23,11 @@ import ( "fmt" "strings" - "github.com/sirupsen/logrus" - "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" + "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/media" "github.com/superseriousbusiness/gotosocial/internal/util" ) @@ -105,7 +104,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A if err == nil { a.AvatarMediaAttachment = avi } else { - logrus.Errorf("AccountToAPIAccountPublic: error getting Avatar with id %s: %s", a.AvatarMediaAttachmentID, err) + log.Errorf("AccountToAPIAccountPublic: error getting Avatar with id %s: %s", a.AvatarMediaAttachmentID, err) } } if a.AvatarMediaAttachment != nil { @@ -123,7 +122,7 @@ func (c *converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A if err == nil { a.HeaderMediaAttachment = avi } else { - logrus.Errorf("AccountToAPIAccountPublic: error getting Header with id %s: %s", a.HeaderMediaAttachmentID, err) + log.Errorf("AccountToAPIAccountPublic: error getting Header with id %s: %s", a.HeaderMediaAttachmentID, err) } } if a.HeaderMediaAttachment != nil { @@ -388,7 +387,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r for _, gtsAttachment := range s.Attachments { apiAttachment, err := c.AttachmentToAPIAttachment(ctx, gtsAttachment) if err != nil { - logrus.Errorf("error converting attachment with id %s: %s", gtsAttachment.ID, err) + log.Errorf("error converting attachment with id %s: %s", gtsAttachment.ID, err) continue } apiAttachments = append(apiAttachments, apiAttachment) @@ -399,12 +398,12 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r for _, aID := range s.AttachmentIDs { gtsAttachment, err := c.db.GetAttachmentByID(ctx, aID) if err != nil { - logrus.Errorf("error getting attachment with id %s: %s", aID, err) + log.Errorf("error getting attachment with id %s: %s", aID, err) continue } apiAttachment, err := c.AttachmentToAPIAttachment(ctx, gtsAttachment) if err != nil { - logrus.Errorf("error converting attachment with id %s: %s", aID, err) + log.Errorf("error converting attachment with id %s: %s", aID, err) continue } apiAttachments = append(apiAttachments, apiAttachment) @@ -418,7 +417,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r for _, gtsMention := range s.Mentions { apiMention, err := c.MentionToAPIMention(ctx, gtsMention) if err != nil { - logrus.Errorf("error converting mention with id %s: %s", gtsMention.ID, err) + log.Errorf("error converting mention with id %s: %s", gtsMention.ID, err) continue } apiMentions = append(apiMentions, apiMention) @@ -429,12 +428,12 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r for _, mID := range s.MentionIDs { gtsMention, err := c.db.GetMention(ctx, mID) if err != nil { - logrus.Errorf("error getting mention with id %s: %s", mID, err) + log.Errorf("error getting mention with id %s: %s", mID, err) continue } apiMention, err := c.MentionToAPIMention(ctx, gtsMention) if err != nil { - logrus.Errorf("error converting mention with id %s: %s", gtsMention.ID, err) + log.Errorf("error converting mention with id %s: %s", gtsMention.ID, err) continue } apiMentions = append(apiMentions, apiMention) @@ -448,7 +447,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r for _, gtsTag := range s.Tags { apiTag, err := c.TagToAPITag(ctx, gtsTag) if err != nil { - logrus.Errorf("error converting tag with id %s: %s", gtsTag.ID, err) + log.Errorf("error converting tag with id %s: %s", gtsTag.ID, err) continue } apiTags = append(apiTags, apiTag) @@ -459,12 +458,12 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r for _, t := range s.TagIDs { gtsTag := >smodel.Tag{} if err := c.db.GetByID(ctx, t, gtsTag); err != nil { - logrus.Errorf("error getting tag with id %s: %s", t, err) + log.Errorf("error getting tag with id %s: %s", t, err) continue } apiTag, err := c.TagToAPITag(ctx, gtsTag) if err != nil { - logrus.Errorf("error converting tag with id %s: %s", gtsTag.ID, err) + log.Errorf("error converting tag with id %s: %s", gtsTag.ID, err) continue } apiTags = append(apiTags, apiTag) @@ -478,7 +477,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r for _, gtsEmoji := range s.Emojis { apiEmoji, err := c.EmojiToAPIEmoji(ctx, gtsEmoji) if err != nil { - logrus.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err) + log.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err) continue } apiEmojis = append(apiEmojis, apiEmoji) @@ -489,12 +488,12 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r for _, e := range s.EmojiIDs { gtsEmoji := >smodel.Emoji{} if err := c.db.GetByID(ctx, e, gtsEmoji); err != nil { - logrus.Errorf("error getting emoji with id %s: %s", e, err) + log.Errorf("error getting emoji with id %s: %s", e, err) continue } apiEmoji, err := c.EmojiToAPIEmoji(ctx, gtsEmoji) if err != nil { - logrus.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err) + log.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err) continue } apiEmojis = append(apiEmojis, apiEmoji) -- cgit v1.2.3