Suppress verbose vips logging output

Initialize libvips with LogLevelError to prevent info-level messages
from polluting the JSON log stream.
Cette révision appartient à :
2026-01-08 16:13:52 -08:00
Parent 3849128c45
révision 982accd549
2 fichiers modifiés avec 14 ajouts et 1 suppressions
+13
Voir le fichier
@@ -6,10 +6,22 @@ import (
"errors"
"fmt"
"io"
"sync"
"github.com/davidbyttow/govips/v2/vips"
)
// vipsOnce ensures vips is initialized exactly once.
var vipsOnce sync.Once
// initVips initializes libvips with quiet logging.
func initVips() {
vipsOnce.Do(func() {
vips.LoggingSettings(nil, vips.LogLevelError)
vips.Startup(nil)
})
}
// MaxInputDimension is the maximum allowed width or height for input images.
// Images larger than this are rejected to prevent DoS via decompression bombs.
const MaxInputDimension = 8192
@@ -25,6 +37,7 @@ type ImageProcessor struct{}
// NewImageProcessor creates a new image processor.
func NewImageProcessor() *ImageProcessor {
initVips()
return &ImageProcessor{}
}
+1 -1
Voir le fichier
@@ -15,7 +15,7 @@ import (
)
func TestMain(m *testing.M) {
vips.Startup(nil)
initVips()
code := m.Run()
vips.Shutdown()
os.Exit(code)