summaryrefslogtreecommitdiff
path: root/examples/spring-boot/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'examples/spring-boot/src/main/java')
-rw-r--r--examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/Application.java12
-rw-r--r--examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/ApplicationLoggingSystem.java22
-rw-r--r--examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RandomNumberParameterProvider.java14
-rw-r--r--examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java33
4 files changed, 81 insertions, 0 deletions
diff --git a/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/Application.java b/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/Application.java
new file mode 100644
index 0000000..d003b3f
--- /dev/null
+++ b/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/Application.java
@@ -0,0 +1,12 @@
+package eu.mulk.quarkus.googlecloud.jsonlogging.example;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/ApplicationLoggingSystem.java b/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/ApplicationLoggingSystem.java
new file mode 100644
index 0000000..4050b99
--- /dev/null
+++ b/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/ApplicationLoggingSystem.java
@@ -0,0 +1,22 @@
+package eu.mulk.quarkus.googlecloud.jsonlogging.example;
+
+import org.springframework.boot.logging.LogFile;
+import org.springframework.boot.logging.LoggingInitializationContext;
+import org.springframework.boot.logging.Slf4JLoggingSystem;
+
+public class ApplicationLoggingSystem extends Slf4JLoggingSystem {
+
+ public ApplicationLoggingSystem(ClassLoader classLoader) {
+ super(classLoader);
+ }
+
+ @Override
+ protected String[] getStandardConfigLocations() {
+ return new String[0];
+ }
+
+ @Override
+ protected void loadDefaults(LoggingInitializationContext initializationContext, LogFile logFile) {
+ /* no configuration necessary */
+ }
+}
diff --git a/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RandomNumberParameterProvider.java b/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RandomNumberParameterProvider.java
new file mode 100644
index 0000000..7e4158c
--- /dev/null
+++ b/examples/spring-boot/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/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java b/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java
new file mode 100644
index 0000000..b3197fd
--- /dev/null
+++ b/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java
@@ -0,0 +1,33 @@
+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 org.jboss.logging.Logger;
+import org.jboss.logging.MDC;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController("/")
+public class RootResource {
+
+ static final Logger log = Logger.getLogger(RootResource.class);
+
+ @PostConstruct
+ public void init() {
+ log.warn("Hey!");
+ }
+
+ @GetMapping(produces = "text/plain")
+ 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";
+ }
+}