summaryrefslogtreecommitdiff
path: root/internal/media/processingmedia.go
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/media/processingmedia.go
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/media/processingmedia.go')
-rw-r--r--internal/media/processingmedia.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go
index 17fddddb7..885e97417 100644
--- a/internal/media/processingmedia.go
+++ b/internal/media/processingmedia.go
@@ -28,11 +28,11 @@ import (
"sync/atomic"
"time"
- "github.com/sirupsen/logrus"
terminator "github.com/superseriousbusiness/exif-terminator"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/uris"
)
@@ -80,10 +80,10 @@ func (p *ProcessingMedia) AttachmentID() string {
// LoadAttachment blocks until the thumbnail and fullsize content
// has been processed, and then returns the completed attachment.
func (p *ProcessingMedia) LoadAttachment(ctx context.Context) (*gtsmodel.MediaAttachment, error) {
- logrus.Tracef("LoadAttachment: getting lock for attachment %s", p.attachment.URL)
+ log.Tracef("LoadAttachment: getting lock for attachment %s", p.attachment.URL)
p.mu.Lock()
defer p.mu.Unlock()
- logrus.Tracef("LoadAttachment: got lock for attachment %s", p.attachment.URL)
+ log.Tracef("LoadAttachment: got lock for attachment %s", p.attachment.URL)
if err := p.store(ctx); err != nil {
return nil, err
@@ -113,7 +113,7 @@ func (p *ProcessingMedia) LoadAttachment(ctx context.Context) (*gtsmodel.MediaAt
p.insertedInDB = true
}
- logrus.Tracef("LoadAttachment: finished, returning attachment %s", p.attachment.URL)
+ log.Tracef("LoadAttachment: finished, returning attachment %s", p.attachment.URL)
return p.attachment, nil
}
@@ -137,7 +137,7 @@ func (p *ProcessingMedia) loadThumb(ctx context.Context) error {
}
// stream the original file out of storage
- logrus.Tracef("loadThumb: fetching attachment from storage %s", p.attachment.URL)
+ log.Tracef("loadThumb: fetching attachment from storage %s", p.attachment.URL)
stored, err := p.storage.GetStream(ctx, p.attachment.File.Path)
if err != nil {
p.err = fmt.Errorf("loadThumb: error fetching file from storage: %s", err)
@@ -147,14 +147,14 @@ func (p *ProcessingMedia) loadThumb(ctx context.Context) error {
// whatever happens, close the stream when we're done
defer func() {
- logrus.Tracef("loadThumb: closing stored stream %s", p.attachment.URL)
+ log.Tracef("loadThumb: closing stored stream %s", p.attachment.URL)
if err := stored.Close(); err != nil {
- logrus.Errorf("loadThumb: error closing stored full size: %s", err)
+ log.Errorf("loadThumb: error closing stored full size: %s", err)
}
}()
// stream the file from storage straight into the derive thumbnail function
- logrus.Tracef("loadThumb: calling deriveThumbnail %s", p.attachment.URL)
+ log.Tracef("loadThumb: calling deriveThumbnail %s", p.attachment.URL)
thumb, err := deriveThumbnail(stored, p.attachment.File.ContentType, createBlurhash)
if err != nil {
p.err = fmt.Errorf("loadThumb: error deriving thumbnail: %s", err)
@@ -163,7 +163,7 @@ func (p *ProcessingMedia) loadThumb(ctx context.Context) error {
}
// put the thumbnail in storage
- logrus.Tracef("loadThumb: storing new thumbnail %s", p.attachment.URL)
+ log.Tracef("loadThumb: storing new thumbnail %s", p.attachment.URL)
if err := p.storage.Put(ctx, p.attachment.Thumbnail.Path, thumb.small); err != nil {
p.err = fmt.Errorf("loadThumb: error storing thumbnail: %s", err)
atomic.StoreInt32(&p.thumbState, int32(errored))
@@ -184,7 +184,7 @@ func (p *ProcessingMedia) loadThumb(ctx context.Context) error {
// we're done processing the thumbnail!
atomic.StoreInt32(&p.thumbState, int32(complete))
- logrus.Tracef("loadThumb: finished processing thumbnail for attachment %s", p.attachment.URL)
+ log.Tracef("loadThumb: finished processing thumbnail for attachment %s", p.attachment.URL)
fallthrough
case complete:
return nil
@@ -245,7 +245,7 @@ func (p *ProcessingMedia) loadFullSize(ctx context.Context) error {
// we're done processing the full-size image
atomic.StoreInt32(&p.fullSizeState, int32(complete))
- logrus.Tracef("loadFullSize: finished processing full size image for attachment %s", p.attachment.URL)
+ log.Tracef("loadFullSize: finished processing full size image for attachment %s", p.attachment.URL)
fallthrough
case complete:
return nil
@@ -270,13 +270,13 @@ func (p *ProcessingMedia) store(ctx context.Context) error {
if err != nil {
return fmt.Errorf("store: error executing data function: %s", err)
}
- logrus.Tracef("store: reading %d bytes from data function for media %s", fileSize, p.attachment.URL)
+ log.Tracef("store: reading %d bytes from data function for media %s", fileSize, p.attachment.URL)
// defer closing the reader when we're done with it
defer func() {
if rc, ok := reader.(io.ReadCloser); ok {
if err := rc.Close(); err != nil {
- logrus.Errorf("store: error closing readcloser: %s", err)
+ log.Errorf("store: error closing readcloser: %s", err)
}
}
}()
@@ -330,7 +330,7 @@ func (p *ProcessingMedia) store(ctx context.Context) error {
defer func() {
if rc, ok := clean.(io.ReadCloser); ok {
if err := rc.Close(); err != nil {
- logrus.Errorf("store: error closing clean readcloser: %s", err)
+ log.Errorf("store: error closing clean readcloser: %s", err)
}
}
}()
@@ -353,7 +353,7 @@ func (p *ProcessingMedia) store(ctx context.Context) error {
return p.postData(ctx)
}
- logrus.Tracef("store: finished storing initial data for attachment %s", p.attachment.URL)
+ log.Tracef("store: finished storing initial data for attachment %s", p.attachment.URL)
return nil
}