From d8e57b67672b345f11b6478cd48f89ece561c949 Mon Sep 17 00:00:00 2001
From: Andreas <andreksv@ntnu.no>
Date: Fri, 3 May 2024 13:41:12 +0200
Subject: [PATCH] refactor/Refactor logging in controller classes

---
 .../bank/controller/AccountController.java    | 12 ++++++---
 .../controller/BankProfileController.java     |  2 +-
 .../controller/TransactionController.java     |  2 +-
 .../bank/service/impl/AccountServiceImpl.java | 14 ++++++++---
 .../service/impl/BankProfileServiceImpl.java  |  2 +-
 .../service/impl/TransactionServiceImpl.java  |  2 +-
 .../controller/badge/BadgeController.java     | 25 ++++++++++++++-----
 .../controller/budget/BudgetController.java   | 15 +++++------
 .../controller/friend/FriendController.java   | 16 ++++++++----
 .../controller/goal/GoalController.java       | 13 ++++++----
 .../controller/item/ItemController.java       |  8 +++---
 .../leaderboard/LeaderboardController.java    | 15 +++++++++--
 .../notification/NotificationController.java  | 12 ++++++---
 .../controller/user/UserController.java       | 16 ++++++------
 14 files changed, 103 insertions(+), 51 deletions(-)

diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/AccountController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/AccountController.java
index bc90732..9ffad90 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/AccountController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/AccountController.java
@@ -41,7 +41,10 @@ public class AccountController {
   @GetMapping("/accounts/profile/{bankProfileId}")
   public ResponseEntity<List<Account>> getAccounts(@PathVariable Long bankProfileId) {
     List<Account> accounts = accountService.getAccountsByBankProfileId(bankProfileId);
-    log.info("[AccountController:getAccounts] accounts: {}", accounts);
+    log.info("[AccountController:getAccounts] bankProfileId: {}", bankProfileId);
+    for (Account account : accounts) {
+      log.info("[AccountController:getAccounts] accountBban: {}", account.getBban());
+    }
     return ResponseEntity.ok(accounts);
   }
 
@@ -55,7 +58,10 @@ public class AccountController {
   @GetMapping("/accounts/ssn/{ssn}")
   public ResponseEntity<List<Account>> getAccountsBySsn(@PathVariable Long ssn) {
     List<Account> accounts = accountService.getAccountsBySsn(ssn);
-    log.info("[AccountController:getAccountsBySsn] accounts: {}", accounts);
+    log.info("[AccountController:getAccountsBySsn] ssn: {}", ssn);
+    for (Account account : accounts) {
+      log.info("[AccountController:getAccountsBySsn] accountBban: {}", account.getBban());
+    }
     return ResponseEntity.ok(accounts);
   }
 
@@ -68,7 +74,7 @@ public class AccountController {
   @PostMapping("/create-account")
   public ResponseEntity<AccountResponseDTO> createAccount(@RequestBody AccountRequestDTO accountRequestDTO) {
     AccountResponseDTO accountResponseDTO = accountService.saveAccount(accountRequestDTO);
-    log.info("[AccountController:createAccount] account: {}", accountResponseDTO);
+    log.info("[AccountController:createAccount] accountBankProfileId: {}", accountResponseDTO.getBankProfileId());
     return ResponseEntity.ok(accountResponseDTO);
   }
 }
\ No newline at end of file
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/BankProfileController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/BankProfileController.java
index 17bdd30..2905a6b 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/BankProfileController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/BankProfileController.java
@@ -34,7 +34,7 @@ public class BankProfileController {
   })
   @PostMapping("/create-profile")
   public BankProfileResponseDTO createBankProfile(@RequestBody BankProfileDTO bankProfileDTO) {
-    log.info("[BankProfileController:createBankProfile] bank-profile: {}", bankProfileDTO);
+    log.info("[BankProfileController:createBankProfile] bank-profileSsn: {}", bankProfileDTO.getSsn());
     return bankProfileService.saveBankProfile(bankProfileDTO);
   }
 
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/TransactionController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/TransactionController.java
index 9f35297..9abda39 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/TransactionController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/controller/TransactionController.java
@@ -36,7 +36,7 @@ public class TransactionController {
   @PostMapping("/norwegian-domestic-payment-to-self")
   public ResponseEntity<TransactionDTO> transferToSelf(@RequestBody TransactionDTO transactionRequest) {
     transactionService.saveTransaction(transactionRequest);
-    log.info("[TransactionController:transferToSelf] transaction: {}", transactionRequest);
+    log.info("[TransactionController:transferToSelf] transaction amount {} from: {} -> {}", transactionRequest.getAmount(), transactionRequest.getCreditorBBAN(), transactionRequest.getDebtorBBAN());
     return ResponseEntity.ok(transactionRequest);
   }
 }
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/AccountServiceImpl.java b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/AccountServiceImpl.java
index af84ded..e373afb 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/AccountServiceImpl.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/AccountServiceImpl.java
@@ -43,7 +43,10 @@ public class AccountServiceImpl implements AccountService {
       throw new ResponseStatusException(HttpStatusCode.valueOf(404), "Bank profile not found");
     }
     accountList = accountRepository.findAllByBankProfileId(id);
-    log.info("[AccountServiceImpl:getAccountsByBankProfileId] accounts: {}", accountList);
+    log.info("[AccountServiceImpl:getAccountsByBankProfileId] bankProfileId: {}", id);
+    for (Account account : accountList) {
+      log.info("[AccountServiceImpl:getAccountsByBankProfileId] accountBban: {}", account.getBban());
+    }
     return accountList;
   }
 
@@ -63,7 +66,10 @@ public class AccountServiceImpl implements AccountService {
       throw new ResponseStatusException(HttpStatusCode.valueOf(404), "Bank profile not found");
     }
     accountList = accountRepository.findAllByBankProfileSsn(ssn);
-    log.info("[AccountServiceImpl:getAccountsBySsn] accounts: {}", accountList);
+    log.info("[AccountServiceImpl:getAccountsBySsn] ssn: {}", ssn);
+    for (Account account : accountList) {
+      log.info("[AccountServiceImpl:getAccountsBySsn] accountBban: {}", account.getBban());
+    }
     return accountList;
   }
 
@@ -89,7 +95,7 @@ public class AccountServiceImpl implements AccountService {
       accountRepository.save(newAccount);
       accountResponseDTO.setBalance(newAccount.getBalance());
       accountResponseDTO.setBankProfileId(newAccount.getBankProfile().getId());
-      log.info("[AccountServiceImpl:saveAccount] account: {}", newAccount);
+      log.info("[AccountServiceImpl:saveAccount] accountBban: {}", newAccount.getBban());
     } catch (Exception e) {
       throw new ResponseStatusException(HttpStatusCode.valueOf(400), e.getMessage());
     }
@@ -109,7 +115,7 @@ public class AccountServiceImpl implements AccountService {
       log.error("[AccountServiceImpl:getAccountByBban] account: Account not found {}", bban);
       throw new ResponseStatusException(HttpStatusCode.valueOf(404), "Account not found");
     }
-    log.info("[AccountServiceImpl:getAccountByBban] account: {}", account);
+    log.info("[AccountServiceImpl:getAccountByBban] accountBban: {}", account.get().getBban());
     return account.get();
   }
 }
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/BankProfileServiceImpl.java b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/BankProfileServiceImpl.java
index b3c4106..331a4c8 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/BankProfileServiceImpl.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/BankProfileServiceImpl.java
@@ -53,7 +53,7 @@ public class BankProfileServiceImpl implements BankProfileService {
           HttpStatusCode.valueOf(400),
           "Could not create bank profile");
     }
-    log.info("[BankProfileServiceImpl:saveBankProfile] bank profile: {}", bankProfileDTO);
+    log.info("[BankProfileServiceImpl:saveBankProfile] bank-profileSsn: {}", bankProfileDTO.getSsn());
     return savedProfileResponse;
   }
 }
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/TransactionServiceImpl.java b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/TransactionServiceImpl.java
index b4b3789..8015b52 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/TransactionServiceImpl.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/bank/service/impl/TransactionServiceImpl.java
@@ -80,7 +80,7 @@ public class TransactionServiceImpl implements TransactionService {
       accountRepository.updateBalance(debtorBalance, debtorAccount.get().getBban());
       accountRepository.updateBalance(creditorBalance, creditorAccount.get().getBban());
       transactionRepository.save(savedTransaction);
-      log.info("[TransactionService:saveTransaction] saved transaction: {}", savedTransaction);
+      log.info("[TransactionService:saveTransaction] saved transaction with id: {}", savedTransaction.getId());
     } catch (Exception e) {
       log.error("[TransactionService:saveTransaction] Transaction failed");
       throw new ResponseStatusException(HttpStatusCode.valueOf(400), e.getMessage());
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/badge/BadgeController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/badge/BadgeController.java
index 2ac80f3..ffbabf7 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/badge/BadgeController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/badge/BadgeController.java
@@ -68,7 +68,7 @@ public class BadgeController {
   public ResponseEntity<BadgeDTO> getBadge(@PathVariable long badgeId) {
     Badge badge = badgeService.findBadgeByBadgeId(badgeId);
     BadgeDTO response = modelMapper.map(badge, BadgeDTO.class);
-    log.info("[BadgeController:getBadge] badge: {}", response);
+    log.info("[BadgeController:getBadge] badge: {}", badge.getId());
     return ResponseEntity.ok(response);
   }
 
@@ -87,7 +87,9 @@ public class BadgeController {
   public ResponseEntity<List<BadgeDTO>> getAllBadges() {
     List<Badge> badges = badgeService.findAllBadges();
     List<BadgeDTO> badgeDTOS = badges.stream().map(badge -> modelMapper.map(badge, BadgeDTO.class)).toList();
-    log.info("[BadgeController:getAllBadges] badges: {}", badgeDTOS);
+    for(BadgeDTO badgeDTO : badgeDTOS) {
+      log.info("[BadgeController:getAllBadges] badge: {}", badgeDTO.getId());
+    }
     return ResponseEntity.ok(badgeDTOS);
   }
 
@@ -107,7 +109,10 @@ public class BadgeController {
   public ResponseEntity<List<BadgeDTO>> getBadgesUnlockedByActiveUser(@AuthenticationPrincipal AuthIdentity identity) {
     List<Badge> badges = badgeService.findBadgesUnlockedByUser(identity.getId());
     List<BadgeDTO> badgeDTOS = badges.stream().map(badge -> modelMapper.map(badge, BadgeDTO.class)).toList();
-    log.info("[BadgeController:getBadgesUnlockedByUser] badges: {}", badgeDTOS);
+    log.info("[BadgeController:getBadgesUnlockedByUser] userId: {}", identity.getId());
+    for(BadgeDTO badgeDTO : badgeDTOS) {
+      log.info("[BadgeController:getBadgesUnlockedByUser] badge: {}", badgeDTO.getId());
+    }
     return ResponseEntity.ok(badgeDTOS);
   }
 
@@ -127,7 +132,10 @@ public class BadgeController {
   public ResponseEntity<List<BadgeDTO>> getBadgesUnlockedByUser(@PathVariable Long userId) {
     List<Badge> badges = badgeService.findBadgesUnlockedByUser(userId);
     List<BadgeDTO> badgeDTOS = badges.stream().map(badge -> modelMapper.map(badge, BadgeDTO.class)).toList();
-    log.info("[BadgeController:getBadgesUnlockedByUser] badges: {}", badgeDTOS);
+    log.info("[BadgeController:getBadgesUnlockedByUser] userId: {}", userId);
+    for(BadgeDTO badgeDTO : badgeDTOS) {
+      log.info("[BadgeController:getBadgesUnlockedByUser] badge: {}", badgeDTO.getId());
+    }
     return ResponseEntity.ok(badgeDTOS);
   }
 
@@ -147,7 +155,10 @@ public class BadgeController {
   public ResponseEntity<List<BadgeDTO>> getBadgesNotUnlockedByActiveUser(@AuthenticationPrincipal AuthIdentity identity) {
     List<Badge> badges = badgeService.findBadgesNotUnlockedByUser(identity.getId());
     List<BadgeDTO> badgeDTOS = badges.stream().map(badge -> modelMapper.map(badge, BadgeDTO.class)).toList();
-    log.info("[BadgeController:getBadgesNotUnlockedByUser] badges: {}", badgeDTOS);
+    log.info("[BadgeController:getBadgesNotUnlockedByUser] userId: {}", identity.getId());
+    for(BadgeDTO badgeDTO : badgeDTOS) {
+      log.info("[BadgeController:getBadgesNotUnlockedByUser] badge: {}", badgeDTO.getId());
+    }
     return ResponseEntity.ok(badgeDTOS);
   }
 
@@ -178,7 +189,9 @@ public class BadgeController {
       notificationService.updateNotification(notification);
     }
     List<BadgeDTO> badgeDTOS = badges.stream().map(badge -> modelMapper.map(badge, BadgeDTO.class)).toList();
-    log.info("[BadgeController:updateUnlockedBadges] unlocked badges: {}", badgeDTOS);
+    for(BadgeDTO badgeDTO : badgeDTOS) {
+      log.info("[BadgeController:updateUnlockedBadges] badge: {}", badgeDTO.getId());
+    }
     return ResponseEntity.ok(badgeDTOS);
   }
 }
\ No newline at end of file
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/budget/BudgetController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/budget/BudgetController.java
index 69a3cb7..1ebb7ca 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/budget/BudgetController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/budget/BudgetController.java
@@ -74,9 +74,9 @@ public class BudgetController {
     List<BudgetResponseDTO> budgetDTOs = new ArrayList<>();
     for (Budget budget : budgets) {
       budgetDTOs.add(modelMapper.map(budget, BudgetResponseDTO.class));
+      log.info("[BudgetController:getBudgetsByUser] budget: {}", budget.getId());
     }
     Collections.reverse(budgetDTOs);
-    log.info("[BudgetController:getBudgetByUser] budgets: {}", budgetDTOs);
     return ResponseEntity.ok(budgetDTOs);
   }
 
@@ -95,7 +95,7 @@ public class BudgetController {
   public ResponseEntity<BudgetResponseDTO> getBudget(@PathVariable long budgetId) {
     Budget budget = budgetService.findBudgetById(budgetId);
     BudgetResponseDTO response = modelMapper.map(budget, BudgetResponseDTO.class);
-    log.info("[BudgetController:getBudget] budget: {}", response);
+    log.info("[BudgetController:getBudget] budget: {}", response.getId());
     return ResponseEntity.ok(response);
   }
 
@@ -118,7 +118,7 @@ public class BudgetController {
     budget.setUser(userService.findById(identity.getId()));
     budget.setCreatedAt(Timestamp.from(Instant.now()));
     budgetService.createBudget(budget);
-    log.info("[BudgetController:createBudget] budget created: {}", budget);
+    log.info("[BudgetController:createBudget] budget created: {}", budget.getId());
     return ResponseEntity.ok().build();
   }
 
@@ -142,7 +142,7 @@ public class BudgetController {
     budget.setBudgetAmount(request.getBudgetAmount());
     budget.setExpenseAmount(request.getExpenseAmount());
     budgetService.updateBudget(budget);
-    log.info("[BudgetController:updateBudget] budget updated: {}", budget);
+    log.info("[BudgetController:updateBudget] budget updated: {}", budget.getId());
     return ResponseEntity.ok().build();
   }
 
@@ -183,7 +183,7 @@ public class BudgetController {
     Expense expense = modelMapper.map(request, Expense.class);
     expense.setBudget(budget);
     budgetService.createExpense(expense);
-    log.info("[BudgetController:updateExpense] expense updated: {}", expense);
+    log.info("[BudgetController:updateExpense] expense updated: {}", expense.getId());
     return ResponseEntity.ok(request);
   }
 
@@ -202,7 +202,7 @@ public class BudgetController {
   public ResponseEntity<ExpenseResponseDTO> getExpense(@PathVariable Long expenseId) {
     Expense expense = budgetService.findExpenseById(expenseId);
     ExpenseResponseDTO response = modelMapper.map(expense, ExpenseResponseDTO.class);
-    log.info("[BudgetController:getExpense] expense: {}", response);
+    log.info("[BudgetController:getExpense] expense: {}", response.getExpenseId());
     return ResponseEntity.ok(response);
   }
 
@@ -221,11 +221,12 @@ public class BudgetController {
   public ResponseEntity<List<ExpenseResponseDTO>> getExpenses(@PathVariable Long budgetId) {
     List<Expense> expenses = budgetService.findExpensesByBudgetId(budgetId);
     List<ExpenseResponseDTO> expenseDTOs = new ArrayList<>();
+    log.info("[BudgetController:getExpenses] budget: {}", budgetId);
     for (Expense expense : expenses) {
       expenseDTOs.add(modelMapper.map(expense, ExpenseResponseDTO.class));
+      log.info("[BudgetController:getExpenses] expense: {}", expense.getId());
     }
     Collections.reverse(expenseDTOs);
-    log.info("[BudgetController:getExpenses] expenses: {}", expenseDTOs);
     return ResponseEntity.ok(expenseDTOs);
   }
 
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/friend/FriendController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/friend/FriendController.java
index 6a6d4b0..c2f0c6a 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/friend/FriendController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/friend/FriendController.java
@@ -61,7 +61,10 @@ public class FriendController {
     @GetMapping
     public ResponseEntity<List<UserDTO>> getFriends(@AuthenticationPrincipal AuthIdentity identity) {
         List<User> friendsUser = userService.getFriends(identity.getId());
-        log.info("[FriendController:getFriends] friends: {}", friendsUser);
+        log.info("[FriendController:getFriends] user: {}", identity.getId());
+        for (User user : friendsUser) {
+            log.info("[FriendController:getFriends] friend: {}", user.getId());
+        }
         return ResponseEntity.ok(convertToDto(friendsUser));
     }
 
@@ -72,7 +75,10 @@ public class FriendController {
     @GetMapping("/requests")
     public ResponseEntity<List<UserDTO>> getFriendRequests(@AuthenticationPrincipal AuthIdentity identity) {
         List<User> friendsUser = userService.getFriendRequests(identity.getId());
-        log.info("[FriendController:getFriendRequests] friend requests: {}", friendsUser);
+        log.info("[FriendController:getFriendRequests] user: {}", identity.getId());
+        for (User user : friendsUser) {
+            log.info("[FriendController:getFriendRequests] friend requests: {}", user.getId());
+        }
         return ResponseEntity.ok(convertToDto(friendsUser));
     }
 
@@ -89,7 +95,7 @@ public class FriendController {
         Notification notification = new Notification(null, friend, "You have received a new friend request from " + user.getFirstName(), true,
             NotificationType.FRIEND_REQUEST, Timestamp.from(Instant.now()));
         notificationService.updateNotification(notification);
-        log.info("[FriendController:addFriendRequest] from: {} to: {}", user, friend);
+        log.info("[FriendController:addFriendRequest] from: {} to: {}", user.getId(), friend.getId());
     }
 
     @Operation(summary = "Accept a friend request", description = "Accepts a friend request from another user.")
@@ -107,7 +113,7 @@ public class FriendController {
             return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No friend request found.");
         }
         friendService.acceptFriendRequest(friendRequest);
-        log.info("[FriendController:acceptFriendRequest] Friend request successfully accepted between: {} and: {}", user, friend);
+        log.info("[FriendController:acceptFriendRequest] Friend request successfully accepted between: {} and: {}", user.getId(), friend.getId());
         return ResponseEntity.ok().build();
     }
 
@@ -128,7 +134,7 @@ public class FriendController {
         }
 
         friendService.deleteFriendOrFriendRequest(friendStatus);
-        log.info("[FriendController:acceptFriendRequest] Friend request successfully deleted between: {} and: {}", user, friend);
+        log.info("[FriendController:acceptFriendRequest] Friend request successfully deleted between: {} and: {}", user.getId(), friend.getId());
         return ResponseEntity.ok().build();
     }
 
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/goal/GoalController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/goal/GoalController.java
index ca2aaea..d523fdd 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/goal/GoalController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/goal/GoalController.java
@@ -65,7 +65,7 @@ public class GoalController {
     Goal createGoal = modelMapper.map(request, Goal.class);
     Goal goal = goalService.createGoal(createGoal, identity.getId());
     GoalDTO goalDTO = modelMapper.map(goal, GoalDTO.class);
-    log.info("[GoalController:createGoal] goal: {}", goalDTO);
+    log.info("[GoalController:createGoal] goal: {}", goalDTO.getId());
     return ResponseEntity.status(HttpStatus.CREATED).body(goalDTO);
   }
 
@@ -83,7 +83,10 @@ public class GoalController {
   public ResponseEntity<List<GoalDTO>> getGoals(@AuthenticationPrincipal AuthIdentity identity) {
     List<Goal> goals = goalService.getGoals(identity.getId());
     List<GoalDTO> goalsDTO = goals.stream().map(goal -> modelMapper.map(goal, GoalDTO.class)).toList();
-    log.info("[GoalController:getGoals] goals: {}", goalsDTO);
+    log.info("[GoalController:getGoals] user: {}", identity.getId());
+    for(GoalDTO goalDTO : goalsDTO) {
+      log.info("[GoalController:getGoals] goal: {}", goalDTO.getId());
+    }
     return ResponseEntity.ok(goalsDTO);
   }
 
@@ -109,7 +112,7 @@ public class GoalController {
                                               @RequestBody MarkChallengeDTO request) {
     challengeService.updateProgress(identity.getId(), request.getId(),
         request.getDay(), request.getAmount());
-    log.info("[GoalController:updateChallenge] challenge: {}", request);
+    log.info("[GoalController:updateChallenge] challenge: {}", request.getId());
     return ResponseEntity.status(HttpStatus.ACCEPTED).build();
   }
 
@@ -130,7 +133,7 @@ public class GoalController {
   public ResponseEntity<Void> updateChallengeAmount(@AuthenticationPrincipal AuthIdentity identity,
                                                     @RequestBody MarkChallengeDTO request) {
     challengeService.updateSavingAmount(identity.getId(), request.getId(), request.getAmount());
-    log.info("[GoalController:updateChallengeAmount] challenge: {}", request);
+    log.info("[GoalController:updateChallengeAmount] challenge: {}", request.getId());
     return ResponseEntity.status(HttpStatus.ACCEPTED).build();
   }
 
@@ -138,7 +141,7 @@ public class GoalController {
   public ResponseEntity<GoalDTO> getGoal(@PathVariable Long id) {
     Goal goal = goalService.getGoal(id);
     GoalDTO goalDTO = modelMapper.map(goal, GoalDTO.class);
-    log.info("[GoalController:getGoal] goal: {}", goalDTO);
+    log.info("[GoalController:getGoal] goal: {}", goalDTO.getId());
     return ResponseEntity.ok(goalDTO);
   }
 
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/item/ItemController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/item/ItemController.java
index 07e059b..e742dc3 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/item/ItemController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/item/ItemController.java
@@ -62,9 +62,9 @@ public class ItemController {
             if(inventory.contains(item)) {
                 itemDTO.setAlreadyBought(true);
             }
+            log.info("[ItemController:getStore] item: {}", itemDTO.getId());
             storeDTO.add(itemDTO);
         }
-        log.info("[ItemController:getStore] store: {}", storeDTO);
         return ResponseEntity.ok(storeDTO);
     }
 
@@ -78,8 +78,8 @@ public class ItemController {
         List<InventoryDTO> inventoryDTO = new ArrayList<>();
         for(Item item : inventory) {
             inventoryDTO.add(modelMapper.map(item, InventoryDTO.class));
+            log.info("[ItemController:getInventory] item: {}", item.getId());
         }
-        log.info("[ItemController:getInventory] inventory: {}", inventoryDTO);
         return ResponseEntity.ok(inventoryDTO);
     }
 
@@ -93,8 +93,8 @@ public class ItemController {
         List<InventoryDTO> inventoryDTO = new ArrayList<>();
         for(Item item : inventory) {
             inventoryDTO.add(modelMapper.map(item, InventoryDTO.class));
+            log.info("[ItemController:getInventoryByUserId] item: {}", item.getId());
         }
-        log.info("[ItemController:getInventoryByUserId] inventory: {}", inventoryDTO);
         return ResponseEntity.ok(inventoryDTO);
     }
 
@@ -111,7 +111,7 @@ public class ItemController {
         boolean purchaseSuccessful = itemService.addItem(user, item);
 
         if (purchaseSuccessful) {
-            log.info("[ItemController:buyItem] item: {}, user: {}", item, user);
+            log.info("[ItemController:buyItem] item: {}, user: {}", item.getId(), user.getId());
             return ResponseEntity.status(HttpStatus.CREATED).build();
         } else {
             log.error("[ItemController:buyItem] Insufficient points to purchase the item");
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/leaderboard/LeaderboardController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/leaderboard/LeaderboardController.java
index 380427f..3547801 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/leaderboard/LeaderboardController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/leaderboard/LeaderboardController.java
@@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import no.ntnu.idi.stud.savingsapp.dto.leaderboard.LeaderboardDTO;
+import no.ntnu.idi.stud.savingsapp.dto.leaderboard.LeaderboardEntryDTO;
 import no.ntnu.idi.stud.savingsapp.model.leaderboard.Leaderboard;
 import no.ntnu.idi.stud.savingsapp.model.leaderboard.LeaderboardFilter;
 import no.ntnu.idi.stud.savingsapp.model.leaderboard.LeaderboardType;
@@ -59,7 +60,12 @@ public class LeaderboardController {
     Leaderboard leaderboard = leaderboardService.getTopUsers(
         LeaderboardType.valueOf(type), LeaderboardFilter.valueOf(filter), entryCount, identity.getId());
     LeaderboardDTO leaderboardDTO = modelMapper.map(leaderboard, LeaderboardDTO.class);
-    log.info("[LeaderboardController:getLeaderboard] leaderboard: {}", leaderboardDTO);
+    log.info("[LeaderboardController:getLeaderboard] type: {}, filter: {}, count: {}",
+        type, filter, entryCount);
+    for(LeaderboardEntryDTO leaderboardEntryDTO : leaderboardDTO.getEntries()) {
+        log.info("[LeaderboardController:getLeaderboard] entry: {}, rank: {}, score: {}",
+            leaderboardEntryDTO.getUser().getId(), leaderboardEntryDTO.getRank(), leaderboardEntryDTO.getScore());
+    }
     return ResponseEntity.ok(leaderboardDTO);
   }
 
@@ -83,7 +89,12 @@ public class LeaderboardController {
     Leaderboard leaderboard = leaderboardService.getSurrounding(
         LeaderboardType.valueOf(type), LeaderboardFilter.valueOf(filter), entryCount, identity.getId());
     LeaderboardDTO leaderboardDTO = modelMapper.map(leaderboard, LeaderboardDTO.class);
-    log.info("[LeaderboardController:getSurrounding] leaderboard: {}", leaderboardDTO);
+    log.info("[LeaderboardController:getLeaderboard] type: {}, filter: {}, count: {}",
+        type, filter, entryCount);
+    for(LeaderboardEntryDTO leaderboardEntryDTO : leaderboardDTO.getEntries()) {
+        log.info("[LeaderboardController:getLeaderboard] entry: {}, rank: {}, score: {}",
+            leaderboardEntryDTO.getUser().getId(), leaderboardEntryDTO.getRank(), leaderboardEntryDTO.getScore());
+    }
     return ResponseEntity.ok(leaderboardDTO);
   }
 
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/notification/NotificationController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/notification/NotificationController.java
index 293ae33..57b361d 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/notification/NotificationController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/notification/NotificationController.java
@@ -63,7 +63,7 @@ public class NotificationController {
   public ResponseEntity<NotificationDTO> getNotification(@PathVariable long notificationId) {
     Notification notification = notificationService.getNotificationById(notificationId);
     NotificationDTO response = modelMapper.map(notification, NotificationDTO.class);
-    log.info("[NotificationController:getNotification] notification: {}", response);
+    log.info("[NotificationController:getNotification] notification: {}", response.getId());
     return ResponseEntity.ok(response);
   }
 
@@ -82,7 +82,9 @@ public class NotificationController {
   public ResponseEntity<List<NotificationDTO>> getNotificationByUser(@AuthenticationPrincipal AuthIdentity identity) {
     List<Notification> notifications = notificationService.getNotificationsByUserId(identity.getId());
     List<NotificationDTO> notificationDTOs = notifications.stream().map(notification -> modelMapper.map(notification, NotificationDTO.class)).toList();
-    log.info("[NotificationController:getNotificationByUser] notifications: {}", notificationDTOs);
+    for (NotificationDTO notificationDTO : notificationDTOs) {
+      log.info("[NotificationController:getNotificationByUser] notification: {}", notificationDTO.getId());
+    }
     return ResponseEntity.ok(notificationDTOs);
   }
 
@@ -101,7 +103,9 @@ public class NotificationController {
   public ResponseEntity<List<NotificationDTO>> getUnreadNotificationByUser(@AuthenticationPrincipal AuthIdentity identity) {
     List<Notification> notifications = notificationService.getUnreadNotificationsByUserId(identity.getId());
     List<NotificationDTO> notificationsDTOs = notifications.stream().map(notification -> modelMapper.map(notification, NotificationDTO.class)).toList();
-    log.info("[NotificationController:getUnreadNotificationByUser] notifications: {}", notificationsDTOs);
+    for(NotificationDTO notificationDTO : notificationsDTOs) {
+      log.info("[NotificationController:getUnreadNotificationByUser] notification: {}", notificationDTO.getId());
+    }
     return ResponseEntity.ok(notificationsDTOs);
   }
 
@@ -127,7 +131,7 @@ public class NotificationController {
     User user = userService.findById(identity.getId());
     notification.setUser(user);
     notificationService.updateNotification(notification);
-    log.info("[NotificationController:updateNotification] updated notification: {}", request);
+    log.info("[NotificationController:updateNotification] updated notification: {}", request.getId());
     return ResponseEntity.ok().build();
   }
 }
diff --git a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/user/UserController.java b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/user/UserController.java
index add2356..e32d27b 100644
--- a/src/main/java/no/ntnu/idi/stud/savingsapp/controller/user/UserController.java
+++ b/src/main/java/no/ntnu/idi/stud/savingsapp/controller/user/UserController.java
@@ -70,7 +70,7 @@ public class UserController {
   public ResponseEntity<UserDTO> getUser(@AuthenticationPrincipal AuthIdentity identity) {
     User user = userService.findById(identity.getId());
     UserDTO userDTO = modelMapper.map(user, UserDTO.class);
-    log.info("[UserController:getUser] user: {}", userDTO);
+    log.info("[UserController:getUser] user: {}", userDTO.getId());
     return ResponseEntity.ok(userDTO);
   }
 
@@ -90,7 +90,7 @@ public class UserController {
   public ResponseEntity<ProfileDTO> getProfile(@PathVariable long userId) {
     User user = userService.findById(userId);
     ProfileDTO profileDTO = modelMapper.map(user, ProfileDTO.class);
-    log.info("[UserController:getProfile] profile: {}", profileDTO);
+    log.info("[UserController:getProfile] profile: {}", profileDTO.getId());
     return ResponseEntity.ok(profileDTO);
   }
 
@@ -211,7 +211,7 @@ public class UserController {
       @RequestBody @Valid BankAccountDTO bankAccountDTO) {
     BankAccountType accountType = modelMapper.map(bankAccountDTO.getBankAccountType(),
         BankAccountType.class);
-    log.info("[UserController:selectBankAccount], bankAccount: {}", bankAccountDTO);
+    log.info("[UserController:selectBankAccount], bankAccountBban: {}", bankAccountDTO.getBban());
     return userService.selectBankAccount(
         accountType,
         bankAccountDTO.getBban(),
@@ -233,8 +233,8 @@ public class UserController {
           for(User user : users) {
             UserDTO userDTO = modelMapper.map(user, UserDTO.class);
             userDTOs.add(userDTO);
+            log.info("[UserController:getUsersByNameAndFilter] user: {}", userDTO.getId());
           }
-          log.info("[UserController:getRandomUsers] random users: {}", userDTOs);
           return ResponseEntity.ok(userDTOs);
   }
 
@@ -248,7 +248,7 @@ public class UserController {
   @PostMapping("/send-feedback")
   public ResponseEntity<Void> sendFeedback(@Validated @RequestBody FeedbackRequestDTO feedbackRequestDTO) {
     userService.sendFeedback(feedbackRequestDTO.getEmail(), feedbackRequestDTO.getMessage());
-    log.info("[UserController:sendFeedback] feedback: {}", feedbackRequestDTO);
+    log.info("[UserController:sendFeedback] feedback: {}", feedbackRequestDTO.getMessage());
     return ResponseEntity.ok().build();
   }
 
@@ -270,7 +270,9 @@ public class UserController {
     }
     List<Feedback> feedbacks = userService.getFeedback();
     List<FeedbackResponseDTO> feedbackResponseDTOS = feedbacks.stream().map(quiz -> modelMapper.map(quiz, FeedbackResponseDTO.class)).toList();
-    log.info("[UserController:getFeedback] feedback: {}", feedbackResponseDTOS);
+    for(FeedbackResponseDTO feedbackResponseDTO : feedbackResponseDTOS) {
+      log.info("[UserController:getFeedback] feedback: {}", feedbackResponseDTO.getId());
+    }
     return ResponseEntity.ok(feedbackResponseDTOS);
   }
   
@@ -289,8 +291,8 @@ public class UserController {
           for(User user : users) {
             UserDTO userDTO = modelMapper.map(user, UserDTO.class);
             userDTOs.add(userDTO);
+            log.info("[UserController:getRandomUsers] user: {}", userDTO.getId());
           }
-          log.info("[UserController:getUsersByNameAndFilter] users: {}", userDTOs);
           return ResponseEntity.ok(userDTOs);
   }
 
-- 
GitLab