summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorclecius <clecius.martinkoski@gmail.com>2022-08-08 17:42:32 -0300
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2022-09-03 18:39:44 +0200
commit5303673160fb8a52102a55774eb99dae1ebf5eda (patch)
treec78b84d43934dd28689556a676731df46b653263 /runtime/src
parentc567bf458883882e23cf642098e764c61d2ae094 (diff)
Quarkus: On/off toggle via configuration.
Change-Id: I2b1b5796501784b4e21697fea85d5e1e12a3e12b
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingRecorder.java7
-rw-r--r--runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleJsonLogConfig.java28
2 files changed, 34 insertions, 1 deletions
diff --git a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingRecorder.java b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingRecorder.java
index 7366a55..8bdb308 100644
--- a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingRecorder.java
+++ b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingRecorder.java
@@ -10,6 +10,7 @@ import eu.mulk.quarkus.googlecloud.jsonlogging.StructuredParameterProvider;
import io.quarkus.arc.Arc;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
+
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -26,7 +27,10 @@ public class GoogleCloudJsonLoggingRecorder {
*
* @return the registered {@link Formatter}.
*/
- public RuntimeValue<Optional<java.util.logging.Formatter>> initialize() {
+ public RuntimeValue<Optional<java.util.logging.Formatter>> initialize(GoogleJsonLogConfig config) {
+ if(!config.jsonGoogle.enable) {
+ return new RuntimeValue<>(Optional.empty());
+ }
var parameterProviders =
Arc.container().select(StructuredParameterProvider.class).stream()
@@ -37,4 +41,5 @@ public class GoogleCloudJsonLoggingRecorder {
return new RuntimeValue<>(Optional.of(Formatter.load(parameterProviders, labelProviders)));
}
+
}
diff --git a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleJsonLogConfig.java b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleJsonLogConfig.java
new file mode 100644
index 0000000..b73b0bc
--- /dev/null
+++ b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleJsonLogConfig.java
@@ -0,0 +1,28 @@
+package eu.mulk.quarkus.googlecloud.jsonlogging.runtime;
+
+import io.quarkus.runtime.annotations.*;
+
+/**
+ * Configuration for Google JSON log formatting.
+ */
+@ConfigRoot(phase = ConfigPhase.RUN_TIME, name = "log.console")
+public class GoogleJsonLogConfig {
+
+ /**
+ * Console google json logging.
+ */
+ @ConfigDocSection
+ @ConfigItem(name = "json.google")
+ JsonConfig jsonGoogle;
+
+ @ConfigGroup
+ public static class JsonConfig {
+
+ /**
+ * Determine whether to enable the JSON console formatting extension, which disables "normal" console formatting.
+ */
+ @ConfigItem(name = ConfigItem.PARENT, defaultValue = "true")
+ boolean enable;
+
+ }
+} \ No newline at end of file