summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
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