summaryrefslogtreecommitdiff
path: root/internal/typeutils
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-07-19 09:47:55 +0100
committerLibravatar GitHub <noreply@github.com>2022-07-19 10:47:55 +0200
commit098dbe6ff4f59652181c8e0e3873fbfcf0e65ea3 (patch)
tree17036ad9db68c3080e1e91279c8bce9f9ea6e5c3 /internal/typeutils
parent[bugfix] Markdown format fixes (#718) (diff)
downloadgotosocial-098dbe6ff4f59652181c8e0e3873fbfcf0e65ea3.tar.xz
[chore] use our own logging implementation (#716)
* first commit Signed-off-by: kim <grufwub@gmail.com> * replace logging with our own log library Signed-off-by: kim <grufwub@gmail.com> * fix imports Signed-off-by: kim <grufwub@gmail.com> * fix log imports Signed-off-by: kim <grufwub@gmail.com> * add license text Signed-off-by: kim <grufwub@gmail.com> * fix package import cycle between config and log package Signed-off-by: kim <grufwub@gmail.com> * fix empty kv.Fields{} being passed to WithFields() Signed-off-by: kim <grufwub@gmail.com> * fix uses of log.WithFields() with whitespace issues and empty slices Signed-off-by: kim <grufwub@gmail.com> * *linter related grumbling* Signed-off-by: kim <grufwub@gmail.com> * gofmt the codebase! also fix more log.WithFields() formatting issues Signed-off-by: kim <grufwub@gmail.com> * update testrig code to match new changes Signed-off-by: kim <grufwub@gmail.com> * fix error wrapping in non fmt.Errorf function Signed-off-by: kim <grufwub@gmail.com> * add benchmarking of log.Caller() vs non-cached Signed-off-by: kim <grufwub@gmail.com> * fix syslog tests, add standard build tags to test runner to ensure consistency Signed-off-by: kim <grufwub@gmail.com> * make syslog tests more robust Signed-off-by: kim <grufwub@gmail.com> * fix caller depth arithmatic (is that how you spell it?) Signed-off-by: kim <grufwub@gmail.com> * update to use unkeyed fields in kv.Field{} instances Signed-off-by: kim <grufwub@gmail.com> * update go-kv library Signed-off-by: kim <grufwub@gmail.com> * update libraries list Signed-off-by: kim <grufwub@gmail.com> * fuck you linter get nerfed Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com>
Diffstat (limited to 'internal/typeutils')
-rw-r--r--internal/typeutils/astointernal.go5
-rw-r--r--internal/typeutils/internaltoas.go6
-rw-r--r--internal/typeutils/internaltofrontend.go31
-rw-r--r--internal/typeutils/wrap.go1
4 files changed, 20 insertions, 23 deletions
diff --git a/internal/typeutils/astointernal.go b/internal/typeutils/astointernal.go
index d50310ff8..e30608150 100644
--- a/internal/typeutils/astointernal.go
+++ b/internal/typeutils/astointernal.go
@@ -23,11 +23,10 @@ import (
"errors"
"fmt"
- "github.com/sirupsen/logrus"
-
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
)
func (c *converter) ASRepresentationToAccount(ctx context.Context, accountable ap.Accountable, accountDomain string, update bool) (*gtsmodel.Account, error) {
@@ -185,7 +184,7 @@ func (c *converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
}
status.URI = uriProp.GetIRI().String()
- l := logrus.WithField("statusURI", status.URI)
+ l := log.WithField("statusURI", status.URI)
// web url for viewing this status
if statusURL, err := ap.ExtractURL(statusable); err == nil {
diff --git a/internal/typeutils/internaltoas.go b/internal/typeutils/internaltoas.go
index a14a3dbab..bb611dd8f 100644
--- a/internal/typeutils/internaltoas.go
+++ b/internal/typeutils/internaltoas.go
@@ -25,13 +25,13 @@ import (
"fmt"
"net/url"
- "github.com/sirupsen/logrus"
"github.com/superseriousbusiness/activity/pub"
"github.com/superseriousbusiness/activity/streams"
"github.com/superseriousbusiness/activity/streams/vocab"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
)
// const (
@@ -219,7 +219,7 @@ func (c *converter) AccountToAS(ctx context.Context, a *gtsmodel.Account) (vocab
if err == nil {
a.AvatarMediaAttachment = avatar
} else {
- logrus.Errorf("AccountToAS: error getting Avatar with id %s: %s", a.AvatarMediaAttachmentID, err)
+ log.Errorf("AccountToAS: error getting Avatar with id %s: %s", a.AvatarMediaAttachmentID, err)
}
}
@@ -253,7 +253,7 @@ func (c *converter) AccountToAS(ctx context.Context, a *gtsmodel.Account) (vocab
if err == nil {
a.HeaderMediaAttachment = header
} else {
- logrus.Errorf("AccountToAS: error getting Header with id %s: %s", a.HeaderMediaAttachmentID, err)
+ log.Errorf("AccountToAS: error getting Header with id %s: %s", a.HeaderMediaAttachmentID, err)
}
}
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 := &gtsmodel.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 := &gtsmodel.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)
diff --git a/internal/typeutils/wrap.go b/internal/typeutils/wrap.go
index 81e8e53de..c81bf14f1 100644
--- a/internal/typeutils/wrap.go
+++ b/internal/typeutils/wrap.go
@@ -14,7 +14,6 @@ import (
)
func (c *converter) WrapPersonInUpdate(person vocab.ActivityStreamsPerson, originAccount *gtsmodel.Account) (vocab.ActivityStreamsUpdate, error) {
-
update := streams.NewActivityStreamsUpdate()
// set the actor