Use logger from request context. (#3623)

That will have projectID and can potentially be used for project level
logging if we are able to pass around the project logger more.
This commit is contained in:
Raja Subramanian
2025-04-24 11:34:16 +05:30
committed by GitHub
parent 34a2e2c107
commit b760918a0d
3 changed files with 6 additions and 4 deletions
+2 -2
View File
@@ -22,8 +22,8 @@ import (
"regexp"
"strings"
"github.com/livekit/livekit-server/pkg/utils"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
)
func handleError(w http.ResponseWriter, r *http.Request, status int, err error, keysAndValues ...interface{}) {
@@ -32,7 +32,7 @@ func handleError(w http.ResponseWriter, r *http.Request, status int, err error,
keysAndValues = append(keysAndValues, "method", r.Method, "path", r.URL.Path)
}
if !errors.Is(err, context.Canceled) && !errors.Is(r.Context().Err(), context.Canceled) {
logger.GetLogger().WithCallDepth(1).Warnw("error handling request", err, keysAndValues...)
utils.GetLogger(r.Context()).WithCallDepth(1).Warnw("error handling request", err, keysAndValues...)
}
w.WriteHeader(status)
_, _ = w.Write([]byte(err.Error()))