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