From 78d803c91b604c93da8a63c767b1c9a87899fc8a Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Tue, 11 May 2021 21:44:31 +0200 Subject: Add example project. Change-Id: I782efdfb2b97b7a876dff637da8bac533d681e9b --- example/pom.xml | 44 ++++++++++++++++++++++ .../jsonlogging/example/RootResource.java | 36 ++++++++++++++++++ example/src/main/resources/application.properties | 0 3 files changed, 80 insertions(+) create mode 100644 example/pom.xml create mode 100644 example/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java create mode 100644 example/src/main/resources/application.properties diff --git a/example/pom.xml b/example/pom.xml new file mode 100644 index 0000000..c5c82b2 --- /dev/null +++ b/example/pom.xml @@ -0,0 +1,44 @@ + + + + 4.0.0 + + + eu.mulk.quarkus-googlecloud-jsonlogging + quarkus-googlecloud-jsonlogging-parent + 1.0.0-SNAPSHOT + + + quarkus-googlecloud-jsonlogging-example + Quarkus Google Cloud JSON Logging Extension - Example + + + + io.quarkus + quarkus-resteasy + + + eu.mulk.quarkus-googlecloud-jsonlogging + quarkus-googlecloud-jsonlogging + ${project.version} + + + + + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + + + diff --git a/example/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java b/example/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java new file mode 100644 index 0000000..6fa42cd --- /dev/null +++ b/example/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java @@ -0,0 +1,36 @@ +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(); + } +} diff --git a/example/src/main/resources/application.properties b/example/src/main/resources/application.properties new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3