fix(view): log debug file errors (#1340)

Md Mushfiqur Rahim and FromSi created

## What?

Logs write and close errors when writing debug image protocol output to
files.

The debug logger now wraps `WriteString` and `Close` calls for both
`DEBUG_IMAGE_PROTOCOL_LOG` and `DEBUG_KITTY_LOG`, while keeping the
existing `os.OpenFile` security lint annotations.

## Why?

Closes #751.

Ignoring file write and close errors can hide failures in debug logging
and make image protocol issues harder to diagnose. Logging these errors
through `loglevel.Debugf` keeps failures visible without changing normal
runtime behavior.

---------

Co-authored-by: FromSi <fromsi665@gmail.com>

Change summary

view/html.go | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

Detailed changes

view/html.go 🔗

@@ -266,13 +266,21 @@ func debugImageProtocol(format string, args ...interface{}) {
 	loglevel.Infof("%s", strings.TrimSuffix(msg, "\n"))
 	if path := os.Getenv("DEBUG_IMAGE_PROTOCOL_LOG"); path != "" {
 		if f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil { //nolint:gosec
-			_, _ = f.WriteString(msg)
-			_ = f.Close()
+			if _, err := f.WriteString(msg); err != nil {
+				loglevel.Debugf("image protocol write error: %v", err)
+			}
+			if err := f.Close(); err != nil {
+				loglevel.Debugf("image protocol close error: %v", err)
+			}
 		}
 	} else if path := os.Getenv("DEBUG_KITTY_LOG"); path != "" {
 		if f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil { //nolint:gosec
-			_, _ = f.WriteString(msg)
-			_ = f.Close()
+			if _, err := f.WriteString(msg); err != nil {
+				loglevel.Debugf("image protocol write error: %v", err)
+			}
+			if err := f.Close(); err != nil {
+				loglevel.Debugf("image protocol close error: %v", err)
+			}
 		}
 	}
 }