Skip to content

Commit 839cab1

Browse files
committed
Log playback info decisions by default
1 parent 2e6c690 commit 839cab1

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

internal/proxy/server.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,25 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
103103
s.observePlaybackCheckIn(kind, r)
104104
}
105105

106-
if isPlaybackInfoPath(r.URL.Path) && s.cfg.Transcode.Enabled {
106+
if isPlaybackInfoPath(r.URL.Path) {
107+
itemID := itemIDFromPlaybackPath(r.URL.Path)
108+
if !s.cfg.Transcode.Enabled {
109+
logging.Infof("playbackinfo passthrough item=%s reason=transcode_disabled", itemID)
110+
s.reverseProxy.ServeHTTP(w, r)
111+
return
112+
}
107113
result := policy.ShouldTranscode(r.Header, s.cfg.Clients)
108114
if result.Enabled {
109-
logging.Infof("playbackinfo rewrite item=%s profile=%s", itemIDFromPlaybackPath(r.URL.Path), result.ProfileName)
115+
logging.Infof("playbackinfo rewrite item=%s profile=%s", itemID, result.ProfileName)
110116
s.handlePlaybackInfo(w, r)
111117
return
112118
}
113-
logging.Debugf("playbackinfo passthrough item=%s remote=%s user_agent=%q", itemIDFromPlaybackPath(r.URL.Path), r.RemoteAddr, r.Header.Get("User-Agent"))
119+
reason := "no_matching_profile"
120+
if result.ProfileName != "" {
121+
reason = "profile_transcode_disabled"
122+
}
123+
logging.Infof("playbackinfo passthrough item=%s profile=%s reason=%s", itemID, result.ProfileName, reason)
124+
logging.Debugf("playbackinfo passthrough detail item=%s remote=%s user_agent=%q", itemID, r.RemoteAddr, r.Header.Get("User-Agent"))
114125
}
115126

116127
s.reverseProxy.ServeHTTP(w, r)
@@ -170,7 +181,7 @@ func (s *Server) handlePlaybackInfo(w http.ResponseWriter, r *http.Request) {
170181
http.Error(w, err.Error(), http.StatusBadGateway)
171182
return
172183
}
173-
logging.Debugf("playbackinfo upstream item=%s status=%d content_type=%q bytes=%d", itemIDFromPlaybackPath(r.URL.Path), resp.StatusCode, resp.Header.Get("Content-Type"), len(respBody))
184+
logging.Infof("playbackinfo upstream item=%s status=%d content_type=%q bytes=%d", itemIDFromPlaybackPath(r.URL.Path), resp.StatusCode, resp.Header.Get("Content-Type"), len(respBody))
174185

175186
copyHeaders(w.Header(), resp.Header)
176187
itemID := itemIDFromPlaybackPath(r.URL.Path)
@@ -226,6 +237,11 @@ func (s *Server) handlePlaybackInfo(w http.ResponseWriter, r *http.Request) {
226237
)
227238
}
228239
}
240+
if err == nil && !changed {
241+
logging.Infof("playbackinfo unchanged item=%s reason=no_media_sources", itemID)
242+
}
243+
} else {
244+
logging.Infof("playbackinfo unchanged item=%s reason=non_json_or_missing_item", itemID)
229245
}
230246

231247
w.WriteHeader(resp.StatusCode)

0 commit comments

Comments
 (0)