From fdc12bf18cc9fd6c3bfc1d77599177158950be3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Tue, 19 Aug 2025 19:58:42 -0700 Subject: [PATCH] fix(icon): improve logging messages in resizeIcon function --- internal/reader/icon/finder.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/reader/icon/finder.go b/internal/reader/icon/finder.go index cfcc9022..9f73d566 100644 --- a/internal/reader/icon/finder.go +++ b/internal/reader/icon/finder.go @@ -203,13 +203,13 @@ func resizeIcon(icon *model.Icon) *model.Icon { // minifier.Bytes returns the data unchanged in case of error. icon.Content, err = minifier.Bytes("image/svg+xml", icon.Content) if err != nil { - slog.Error("Unable to minimize the svg file", slog.Any("error", err)) + slog.Error("Unable to minify SVG icon", slog.Any("error", err)) } return icon } if !slices.Contains([]string{"image/jpeg", "image/png", "image/gif", "image/webp"}, icon.MimeType) { - slog.Info("icon isn't a png/gif/jpeg/webp, can't resize", slog.String("mimetype", icon.MimeType)) + slog.Info("Icon resize skipped: unsupported MIME type", slog.String("mime_type", icon.MimeType)) return icon } @@ -218,11 +218,11 @@ func resizeIcon(icon *model.Icon) *model.Icon { // Don't resize icons that we can't decode, or that already have the right size. config, _, err := image.DecodeConfig(r) if err != nil { - slog.Warn("unable to decode the metadata of the icon", slog.Any("error", err)) + slog.Warn("Unable to decode icon metadata", slog.Any("error", err)) return icon } if config.Height <= 32 && config.Width <= 32 { - slog.Debug("icon don't need to be rescaled", slog.Int("height", config.Height), slog.Int("width", config.Width)) + slog.Debug("Icon doesn't need to be resized", slog.Int("height", config.Height), slog.Int("width", config.Width)) return icon } @@ -240,7 +240,7 @@ func resizeIcon(icon *model.Icon) *model.Icon { src, err = webp.Decode(r) } if err != nil || src == nil { - slog.Warn("unable to decode the icon", slog.Any("error", err)) + slog.Warn("Unable to decode icon image", slog.Any("error", err)) return icon } @@ -249,7 +249,8 @@ func resizeIcon(icon *model.Icon) *model.Icon { var b bytes.Buffer if err = png.Encode(io.Writer(&b), dst); err != nil { - slog.Warn("unable to encode the new icon", slog.Any("error", err)) + slog.Warn("Unable to encode resized icon", slog.Any("error", err)) + return icon } icon.Content = b.Bytes()