From 8f02daf337dce8a6bf899a78d2c1fc3a3a7a5bb9 Mon Sep 17 00:00:00 2001 From: Deluan Date: Thu, 3 Nov 2022 12:38:05 -0400 Subject: [PATCH] Reduce spurious error/warn messages, if loglevel != debug --- server/subsonic/api.go | 4 +++- server/subsonic/stream.go | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server/subsonic/api.go b/server/subsonic/api.go index 85665ace4..e4e53bcdf 100644 --- a/server/subsonic/api.go +++ b/server/subsonic/api.go @@ -195,7 +195,9 @@ func h(r chi.Router, path string, f handler) { return } if r.Context().Err() != nil { - log.Warn("Request was interrupted", "path", path, r.Context().Err()) + if log.CurrentLevel() >= log.LevelDebug { + log.Warn("Request was interrupted", "path", path, r.Context().Err()) + } return } if res != nil { diff --git a/server/subsonic/stream.go b/server/subsonic/stream.go index 5f0859aff..c8b356f0f 100644 --- a/server/subsonic/stream.go +++ b/server/subsonic/stream.go @@ -68,10 +68,13 @@ func (c *StreamController) Stream(w http.ResponseWriter, r *http.Request) (*resp if r.Method == "HEAD" { go func() { _, _ = io.Copy(io.Discard, stream) }() } else { - if c, err := io.Copy(w, stream); err != nil { - log.Error(ctx, "Error sending transcoded file", "id", id, err) - } else { - log.Trace(ctx, "Success sending transcode file", "id", id, "size", c) + c, err := io.Copy(w, stream) + if log.CurrentLevel() >= log.LevelDebug { + if err != nil { + log.Error(ctx, "Error sending transcoded file", "id", id, err) + } else { + log.Trace(ctx, "Success sending transcode file", "id", id, "size", c) + } } } }