Skip to content

Commit a4f4f80

Browse files
committed
Feature: Adding logging in IndexController routes
1 parent 92dd793 commit a4f4f80

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
package com.example.easynotes.controller;
2-
3-
2+
import lombok.extern.slf4j.Slf4j;
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
45
import org.springframework.web.bind.annotation.GetMapping;
56
import org.springframework.web.bind.annotation.RequestMapping;
67
import org.springframework.web.bind.annotation.RestController;
78

89
@RestController
910
@RequestMapping("/")
11+
@Slf4j
1012
public class IndexController {
1113

1214
@GetMapping
1315
public String sayHello() {
14-
return "Hello and Welcome to the EasyNotes application. You can create a new Note by making a POST request to /api/notes endpoint.";
16+
try{
17+
log.info("/ API hit");
18+
return "Hello and Welcome to the EasyNotes application. You can create a new Note by making a POST request to /api/notes endpoint.";
19+
} catch (Exception e ){
20+
log.error("Error:{}",e);
21+
return "Contact Administrator";
22+
}
23+
1524
}
1625
}

0 commit comments

Comments
 (0)