Skip to content

Commit

Permalink
Thumbs: Reduce log level for libvips warnings #1474
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Mayer <michael@photoprism.app>
  • Loading branch information
lastzero committed May 22, 2024
1 parent e35d66e commit 923ee0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions internal/thumb/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,13 @@ func TestCreate(t *testing.T) {
assert.Equal(t, 750, bounds.Max.X)
assert.Equal(t, 500, bounds.Max.Y)

resized, err := Create(img, dst, -5, tile500.Height, tile500.Options...)
_, err = Create(img, dst, -5, tile500.Height, tile500.Options...)

if err == nil {
t.Fatal("error expected")
}

assert.Equal(t, "thumb: width has an invalid value (-5)", err.Error())
t.Log(resized)
})
t.Run("invalid height", func(t *testing.T) {
tile500 := Sizes[Tile500]
Expand Down
8 changes: 4 additions & 4 deletions internal/thumb/vips_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func vipsInit() {
case vips.LogLevelError, vips.LogLevelCritical:
log.Errorf("%s: %s", strings.TrimSpace(strings.ToLower(domain)), msg)
case vips.LogLevelWarning:
log.Warnf("%s: %s", strings.TrimSpace(strings.ToLower(domain)), msg)
log.Debugf("%s: %s", strings.TrimSpace(strings.ToLower(domain)), msg)
default:
log.Tracef("%s: %s", strings.TrimSpace(strings.ToLower(domain)), msg)
}
Expand All @@ -68,11 +68,11 @@ func vipsConfig() *vips.Config {
// vipsLogLevel provides the libvips equivalent of the current log level.
func vipsLogLevel() vips.LogLevel {
switch log.GetLevel() {
case logrus.PanicLevel, logrus.FatalLevel, logrus.ErrorLevel:
return vips.LogLevelError
case logrus.DebugLevel:
return vips.LogLevelWarning
case logrus.TraceLevel:
return vips.LogLevelDebug
default:
return vips.LogLevelWarning
return vips.LogLevelError
}
}

0 comments on commit 923ee0c

Please sign in to comment.