Add missing context to logger calls
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user