Matthias Andreas Benkard | 78d803c | 2021-05-11 21:44:31 +0200 | [diff] [blame] | 1 | package eu.mulk.quarkus.googlecloud.jsonlogging.example; |
| 2 | |
| 3 | import eu.mulk.quarkus.googlecloud.jsonlogging.KeyValueParameter; |
| 4 | import eu.mulk.quarkus.googlecloud.jsonlogging.Label; |
| 5 | import javax.annotation.PostConstruct; |
Matthias Andreas Benkard | 78d803c | 2021-05-11 21:44:31 +0200 | [diff] [blame] | 6 | import org.jboss.logging.Logger; |
| 7 | import org.jboss.logging.MDC; |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 8 | import org.springframework.web.bind.annotation.GetMapping; |
| 9 | import org.springframework.web.bind.annotation.RestController; |
Matthias Andreas Benkard | 78d803c | 2021-05-11 21:44:31 +0200 | [diff] [blame] | 10 | |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 11 | @RestController("/") |
Matthias Andreas Benkard | 78d803c | 2021-05-11 21:44:31 +0200 | [diff] [blame] | 12 | public class RootResource { |
| 13 | |
| 14 | static final Logger log = Logger.getLogger(RootResource.class); |
| 15 | |
| 16 | @PostConstruct |
| 17 | public void init() { |
| 18 | log.warn("Hey!"); |
| 19 | } |
| 20 | |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 21 | @GetMapping(produces = "text/plain") |
Matthias Andreas Benkard | 78d803c | 2021-05-11 21:44:31 +0200 | [diff] [blame] | 22 | public String hello() { |
| 23 | MDC.put("requestMethod", "GET"); |
| 24 | log.infof( |
| 25 | "Hello %s.", |
| 26 | "Mulkiatsch", |
| 27 | KeyValueParameter.of("a", "b"), |
| 28 | Label.of("app", "foo"), |
| 29 | KeyValueParameter.of("version", 10)); |
| 30 | throw new IllegalStateException(); |
Matthias Andreas Benkard | 348f205 | 2022-01-15 16:13:01 +0100 | [diff] [blame] | 31 | // return "ok"; |
Matthias Andreas Benkard | 78d803c | 2021-05-11 21:44:31 +0200 | [diff] [blame] | 32 | } |
| 33 | } |