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
+2 -2
View File
@@ -49,12 +49,12 @@ func handleExportPlaylist(ds model.DataStore) http.HandlerFunc {
plsId := chi.URLParam(r, "playlistId")
pls, err := plsRepo.GetWithTracks(plsId)
if errors.Is(err, model.ErrNotFound) {
log.Warn("Playlist not found", "playlistId", plsId)
log.Warn(r.Context(), "Playlist not found", "playlistId", plsId)
http.Error(w, "not found", http.StatusNotFound)
return
}
if err != nil {
log.Error("Error retrieving the playlist", "playlistId", plsId, err)
log.Error(r.Context(), "Error retrieving the playlist", "playlistId", plsId, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
+6 -6
View File
@@ -27,9 +27,9 @@ var (
translations map[string]translation
)
func newTranslationRepository(context.Context) rest.Repository {
if err := loadTranslations(resources.FS()); err != nil {
log.Error("Error loading translation files", err)
func newTranslationRepository(ctx context.Context) rest.Repository {
if err := loadTranslations(ctx, resources.FS()); err != nil {
log.Error(ctx, "Error loading translation files", err)
}
return &translationRepository{}
}
@@ -66,7 +66,7 @@ func (r *translationRepository) NewInstance() interface{} {
return &translation{}
}
func loadTranslations(fsys fs.FS) (loadError error) {
func loadTranslations(ctx context.Context, fsys fs.FS) (loadError error) {
once.Do(func() {
translations = make(map[string]translation)
dir, err := fsys.Open(consts.I18nFolder)
@@ -83,13 +83,13 @@ func loadTranslations(fsys fs.FS) (loadError error) {
for _, f := range files {
t, err := loadTranslation(fsys, f.Name())
if err != nil {
log.Error("Error loading translation file", "file", f.Name(), err)
log.Error(ctx, "Error loading translation file", "file", f.Name(), err)
continue
}
translations[t.ID] = t
languages = append(languages, t.ID)
}
log.Info("Loading translations", "languages", languages)
log.Info(ctx, "Loading translations", "languages", languages)
})
return
}