summaryrefslogtreecommitdiff
path: root/examples/quarkus/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java
blob: eb4443b9a7bd7ddcee90a1e7853ed781c06f8e02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
//
// SPDX-License-Identifier: GPL-3.0-or-later

package eu.mulk.quarkus.googlecloud.jsonlogging.example;

import eu.mulk.quarkus.googlecloud.jsonlogging.KeyValueParameter;
import eu.mulk.quarkus.googlecloud.jsonlogging.Label;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.jboss.logging.Logger;
import org.jboss.logging.MDC;

@Produces("text/plain")
@Path("/")
@ApplicationScoped
public class RootResource {

  static final Logger log = Logger.getLogger(RootResource.class);

  @PostConstruct
  public void init() {
    log.warn("Hey!");
  }

  @GET
  public String hello() {
    MDC.put("requestMethod", "GET");
    log.infof(
        "Hello %s.",
        "Mulkiatsch",
        KeyValueParameter.of("a", "b"),
        Label.of("app", "foo"),
        KeyValueParameter.of("version", 10));
    throw new IllegalStateException();
    // return "ok";
  }
}