🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Fix overriding previous logger in context
Deluan6489dd4478b4
diff --git a/core/players.go b/core/players.goindex 5bff8211a..47fa30678 100644--- a/core/players.go+++ b/core/players.go@@ -38,7 +38,7 @@ func (p *players) Register(ctx context.Context, id, client, userAgent, ip stringif err != nil || id == "" {plr, err = p.ds.Player(ctx).FindMatch(userName, client, userAgent)if err == nil {- log.Debug("Found matching player", "id", plr.ID, "client", client, "username", userName, "type", userAgent)+ log.Debug(ctx, "Found matching player", "id", plr.ID, "client", client, "username", userName, "type", userAgent)} else {plr = &model.Player{ID: uuid.NewString(),diff --git a/log/log.go b/log/log.goindex 031affb4e..805a9e094 100644--- a/log/log.go+++ b/log/log.go@@ -127,7 +127,11 @@ func NewContext(ctx context.Context, keyValuePairs ...interface{}) context.Contectx = context.Background()}- logger := addFields(createNewLogger(), keyValuePairs)+ logger, ok := ctx.Value(loggerCtxKey).(*logrus.Entry)+ if !ok {+ logger = createNewLogger()+ }+ logger = addFields(logger, keyValuePairs)ctx = context.WithValue(ctx, loggerCtxKey, logger)return ctxdiff --git a/server/subsonic/middlewares.go b/server/subsonic/middlewares.goindex 92c08e682..8e0f930f0 100644--- a/server/subsonic/middlewares.go+++ b/server/subsonic/middlewares.go@@ -100,7 +100,6 @@ func authenticate(ds model.DataStore) func(next http.Handler) http.Handler {ctx = log.NewContext(r.Context(), "username", username)ctx = request.WithUser(ctx, *usr)- ctx = request.WithUsername(ctx, usr.UserName)r = r.WithContext(ctx)next.ServeHTTP(w, r)