Add missing context to logger calls

This commit is contained in:
Deluan
2022-11-04 11:29:58 -04:00
parent daa428ede7
commit 9c433b5d68
11 changed files with 21 additions and 21 deletions
+1 -1
View File
@@ -196,7 +196,7 @@ func h(r chi.Router, path string, f handler) {
}
if r.Context().Err() != nil {
if log.CurrentLevel() >= log.LevelDebug {
log.Warn("Request was interrupted", "path", path, r.Context().Err())
log.Warn(r.Context(), "Request was interrupted", "path", path, r.Context().Err())
}
return
}
+1 -1
View File
@@ -233,7 +233,7 @@ func (c *MediaAnnotationController) scrobblerNowPlaying(ctx context.Context, tra
clientId = player.ID
}
log.Info("Now Playing", "title", mf.Title, "artist", mf.Artist, "user", username, "player", player.Name)
log.Info(ctx, "Now Playing", "title", mf.Title, "artist", mf.Artist, "user", username, "player", player.Name)
err = c.playTracker.NowPlaying(ctx, clientId, client, trackId)
return err
}
+1 -1
View File
@@ -149,7 +149,7 @@ func getPlayer(players core.Players) func(next http.Handler) http.Handler {
userAgent := canonicalUserAgent(r)
player, trc, err := players.Register(ctx, playerId, client, userAgent, ip)
if err != nil {
log.Error("Could not register player", "username", userName, "client", client, err)
log.Error(r.Context(), "Could not register player", "username", userName, "client", client, err)
} else {
ctx = request.WithPlayer(ctx, *player)
if trc != nil {
+1 -1
View File
@@ -44,7 +44,7 @@ func (c *StreamController) Stream(w http.ResponseWriter, r *http.Request) (*resp
// Make sure the stream will be closed at the end, to avoid leakage
defer func() {
if err := stream.Close(); err != nil && log.CurrentLevel() >= log.LevelDebug {
log.Error("Error closing stream", "id", id, "file", stream.Name(), err)
log.Error(r.Context(), "Error closing stream", "id", id, "file", stream.Name(), err)
}
}()