logging added
All checks were successful
ci / build (push) Successful in 2m46s

This commit is contained in:
miwr 2025-04-24 13:16:00 +02:00
parent c009451fa1
commit 74ef072fdb
2 changed files with 10 additions and 1 deletions

View file

@ -1,5 +1,7 @@
package de.telekom.silly_game; package de.telekom.silly_game;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -11,6 +13,8 @@ import java.util.concurrent.atomic.AtomicInteger;
@RequestMapping("/game") @RequestMapping("/game")
public class GameController { public class GameController {
private static final Logger log = LoggerFactory.getLogger(GameController.class);
@GetMapping("/start") @GetMapping("/start")
public String startGame() { public String startGame() {
return "Game started!"; return "Game started!";
@ -24,8 +28,8 @@ public class GameController {
@GetMapping("/jump") @GetMapping("/jump")
public Map<String, Integer> registerJump() { public Map<String, Integer> registerJump() {
System.out.println(domain); System.out.println(domain);
log.atInfo().log("Jump registered");
int total = jumpCount.incrementAndGet(); int total = jumpCount.incrementAndGet();
System.out.println(total);
return Collections.singletonMap("totalJumps", total); return Collections.singletonMap("totalJumps", total);
} }

View file

@ -1,6 +1,8 @@
package de.telekom.silly_game; package de.telekom.silly_game;
import jakarta.mail.internet.MimeMessage; import jakarta.mail.internet.MimeMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSender;
@ -13,6 +15,8 @@ import java.util.Map;
@RequestMapping("/api") @RequestMapping("/api")
public class InviteController { public class InviteController {
private static final Logger log = LoggerFactory.getLogger(GameController.class);
@PostMapping("/invite") @PostMapping("/invite")
public ResponseEntity<?> sendInvite(@RequestBody Map<String, String> payload) { public ResponseEntity<?> sendInvite(@RequestBody Map<String, String> payload) {
String email = payload.get("email"); String email = payload.get("email");
@ -26,6 +30,7 @@ public class InviteController {
helper.setText("Your friend invited you to play a game!", true); helper.setText("Your friend invited you to play a game!", true);
mailSender.send(message); mailSender.send(message);
log.atInfo().log("Invitation sent");
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} catch (Exception e) { } catch (Exception e) {
return ResponseEntity.status(500).body("Failed to send email."); return ResponseEntity.status(500).body("Failed to send email.");