diff --git a/server/backend/cafeteriaRatingDBInitializer.go b/server/backend/cafeteriaRatingDBInitializer.go index f51dd4db..396a7e19 100644 --- a/server/backend/cafeteriaRatingDBInitializer.go +++ b/server/backend/cafeteriaRatingDBInitializer.go @@ -109,7 +109,7 @@ func addNotIncluded(parentId int32, db *gorm.DB, v nameTag) { Select("DishNameTagOptionExcluded"). Count(&count).Error if errorLoadingIncluded != nil { - log.WithError(errorLoadingIncluded).Errorf("Unable to load can be excluded tag with expression %s and parentId %s", u, parentId) + log.WithError(errorLoadingIncluded).Errorf("Unable to load can be excluded tag with expression %s and parentId %d", u, parentId) } else { if count == 0 { createError := db.Model(&model.DishNameTagOptionExcluded{}). @@ -132,7 +132,7 @@ func addCanBeIncluded(parentId int32, db *gorm.DB, v nameTag) { Select("DishNameTagOptionIncluded"). Count(&count).Error if errorLoadingIncluded != nil { - log.WithError(errorLoadingIncluded).Errorf("Unable to load can be included tag with expression %s and parentId %s", u, parentId) + log.WithError(errorLoadingIncluded).Errorf("Unable to load can be included tag with expression %s and parentId %d", u, parentId) } else { if count == 0 { createError := db.Model(&model.DishNameTagOptionIncluded{}). @@ -141,7 +141,7 @@ func addCanBeIncluded(parentId int32, db *gorm.DB, v nameTag) { NameTagID: parentId, }).Error if createError != nil { - log.WithError(errorLoadingIncluded).Errorf("Unable to create new can be excluded tag with expression %s and parentId %s", u, parentId) + log.WithError(errorLoadingIncluded).Errorf("Unable to create new can be excluded tag with expression %s and parentId %d", u, parentId) } } } diff --git a/server/backend/cafeteriaService.go b/server/backend/cafeteriaService.go index 0c79a9be..23b84acd 100644 --- a/server/backend/cafeteriaService.go +++ b/server/backend/cafeteriaService.go @@ -155,7 +155,7 @@ func (s *CampusServer) GetDishRatings(_ context.Context, input *pb.DishRatingReq First(&result) if err.Error != nil { - log.WithError(err.Error).Errorf("Error while querying the average ratings for the dish %s in the cafeteria %s.", dishID, cafeteriaID) + log.WithError(err.Error).Errorf("Error while querying the average ratings for the dish %d in the cafeteria %d", dishID, cafeteriaID) return nil, status.Errorf(codes.Internal, "This dish has not yet been rated.") } diff --git a/server/backend/cron/cronjobs.go b/server/backend/cron/cronjobs.go index 596ed30f..21e325a8 100644 --- a/server/backend/cron/cronjobs.go +++ b/server/backend/cron/cronjobs.go @@ -127,7 +127,7 @@ func (c *CronService) Run() error { err := g.Wait() if err != nil { - log.Println("Couldn't run all cron jobs: %v", err) + log.WithError(err).Error("Couldn't run all cron jobs") } log.Trace("Cron: sleeping for 60 seconds") time.Sleep(60 * time.Second) diff --git a/server/backend/cron/dishNameDownload.go b/server/backend/cron/dishNameDownload.go index 46e2de86..24374ca4 100644 --- a/server/backend/cron/dishNameDownload.go +++ b/server/backend/cron/dishNameDownload.go @@ -209,7 +209,7 @@ func addDishTagsToMapping(dishID int32, dishName string, db *gorm.DB) { NameTagID: a, }).Error if err != nil { - log.WithError(err).Errorf("Error while creating a new entry with dish %s and nametag %s", dishID, a) + log.WithError(err).Errorf("Error while creating a new entry with dish %d and nametag %d", dishID, a) } } } diff --git a/server/backend/cron/news.go b/server/backend/cron/news.go index 95ef7be3..628ae764 100644 --- a/server/backend/cron/news.go +++ b/server/backend/cron/news.go @@ -32,7 +32,7 @@ func (c *CronService) newsCron(cronjob *model.Crontab) error { //check if source id provided for news job is not null if !cronjob.ID.Valid { cronjobJson, _ := json.Marshal(cronjob) - log.Println("skipping news job, id of source is null, cronjob: %s", string(cronjobJson)) + log.Println("skipping news job, id of source is null, cronjob: ", string(cronjobJson)) return nil } // get news source for cronjob diff --git a/server/backend/rpcserver.go b/server/backend/rpcserver.go index 5c974785..9316970c 100644 --- a/server/backend/rpcserver.go +++ b/server/backend/rpcserver.go @@ -153,7 +153,7 @@ func (s *CampusServer) GetTopNews(ctx context.Context, _ *emptypb.Empty) (*pb.Ge var res *model.NewsAlert err := s.db.Joins("Company").Where("NOW() between `from` and `to`").Limit(1).First(&res).Error if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - log.Errorf("Failed to fetch top news: %w", err) + log.WithError(err).Error("Failed to fetch top news") } else if res != nil { return &pb.GetTopNewsReply{ //ImageUrl: res.Name,