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

View file

@ -135,7 +135,7 @@ func createAdmin(ds model.DataStore) func(w http.ResponseWriter, r *http.Request
}
func createAdminUser(ctx context.Context, ds model.DataStore, username, password string) error {
log.Warn("Creating initial user", "user", username)
log.Warn(ctx, "Creating initial user", "user", username)
now := time.Now()
caser := cases.Title(language.Und)
initialUser := model.User{
@ -149,7 +149,7 @@ func createAdminUser(ctx context.Context, ds model.DataStore, username, password
}
err := ds.User(ctx).Put(&initialUser)
if err != nil {
log.Error("Could not create initial user", "user", initialUser, err)
log.Error(ctx, "Could not create initial user", "user", initialUser, err)
}
return nil
}
@ -199,7 +199,7 @@ func UsernameFromReverseProxyHeader(r *http.Request) string {
return ""
}
if !validateIPAgainstList(r.RemoteAddr, conf.Server.ReverseProxyWhitelist) {
log.Warn("IP is not whitelisted for reverse proxy login", "ip", r.RemoteAddr)
log.Warn(r.Context(), "IP is not whitelisted for reverse proxy login", "ip", r.RemoteAddr)
return ""
}
username := r.Header.Get(conf.Server.ReverseProxyUserHeader)