summaryrefslogtreecommitdiff
path: root/examples/quarkus
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quarkus')
-rw-r--r--examples/quarkus/pom.xml44
-rw-r--r--examples/quarkus/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RandomNumberParameterProvider.java14
-rw-r--r--examples/quarkus/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java37
-rw-r--r--examples/quarkus/src/main/resources/META-INF/services/eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameterProvider1
-rw-r--r--examples/quarkus/src/main/resources/application.properties0
5 files changed, 96 insertions, 0 deletions
diff --git a/examples/quarkus/pom.xml b/examples/quarkus/pom.xml
new file mode 100644
index 0000000..a26f782
--- /dev/null
+++ b/examples/quarkus/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId>
+ <artifactId>quarkus-googlecloud-jsonlogging-parent</artifactId>
+ <version>3.1.4-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>quarkus-googlecloud-jsonlogging-quarkus-example</artifactId>
+ <name>Quarkus Google Cloud JSON Logging Extension - Quarkus Example</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId>
+ <artifactId>quarkus-googlecloud-jsonlogging</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/examples/quarkus/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RandomNumberParameterProvider.java b/examples/quarkus/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RandomNumberParameterProvider.java
new file mode 100644
index 0000000..7e4158c
--- /dev/null
+++ b/examples/quarkus/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RandomNumberParameterProvider.java
@@ -0,0 +1,14 @@
+package eu.mulk.quarkus.googlecloud.jsonlogging.example;
+
+import eu.mulk.quarkus.googlecloud.jsonlogging.KeyValueParameter;
+import eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameter;
+import eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameterProvider;
+import java.util.concurrent.ThreadLocalRandom;
+
+public class RandomNumberParameterProvider implements StructuredParameterProvider {
+
+ @Override
+ public StructuredParameter getParameter() {
+ return KeyValueParameter.of("randomNumber", ThreadLocalRandom.current().nextInt());
+ }
+}
diff --git a/examples/quarkus/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java b/examples/quarkus/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java
new file mode 100644
index 0000000..90cd587
--- /dev/null
+++ b/examples/quarkus/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java
@@ -0,0 +1,37 @@
+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";
+ }
+}
diff --git a/examples/quarkus/src/main/resources/META-INF/services/eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameterProvider b/examples/quarkus/src/main/resources/META-INF/services/eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameterProvider
new file mode 100644
index 0000000..c0017e6
--- /dev/null
+++ b/examples/quarkus/src/main/resources/META-INF/services/eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameterProvider
@@ -0,0 +1 @@
+eu.mulk.quarkus.googlecloud.jsonlogging.example.RandomNumberParameterProvider
diff --git a/examples/quarkus/src/main/resources/application.properties b/examples/quarkus/src/main/resources/application.properties
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/quarkus/src/main/resources/application.properties