summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.adoc8
-rw-r--r--deployment/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/deployment/GoogleCloudLoggingProcessor.java7
-rw-r--r--examples/quarkus/pom.xml2
-rw-r--r--examples/quarkus/src/main/resources/application.properties4
-rw-r--r--runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingConfiguration.java22
-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
7 files changed, 41 insertions, 37 deletions
diff --git a/README.adoc b/README.adoc
index 27d8cf8..3460598 100644
--- a/README.adoc
+++ b/README.adoc
@@ -63,6 +63,14 @@ dependencies {
}
----
+By default the extension is turned on. You can turn the extension on
+or off explicitly by configuring the `quarkus.log.console.google` key
+in `application.properties`:
+
+[source,properties]
+----
+quarkus.log.console.google = true
+----
== Activation (Other Frameworks)
diff --git a/deployment/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/deployment/GoogleCloudLoggingProcessor.java b/deployment/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/deployment/GoogleCloudLoggingProcessor.java
index fdfcb1c..8ef0962 100644
--- a/deployment/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/deployment/GoogleCloudLoggingProcessor.java
+++ b/deployment/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/deployment/GoogleCloudLoggingProcessor.java
@@ -4,8 +4,8 @@
package eu.mulk.quarkus.googlecloud.jsonlogging.deployment;
+import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleCloudJsonLoggingConfiguration;
import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleCloudJsonLoggingRecorder;
-import eu.mulk.quarkus.googlecloud.jsonlogging.runtime.GoogleJsonLogConfig;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
@@ -39,7 +39,8 @@ public class GoogleCloudLoggingProcessor {
*/
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
- public LogConsoleFormatBuildItem setUpFormatter(GoogleCloudJsonLoggingRecorder recorder, GoogleJsonLogConfig config) {
- return new LogConsoleFormatBuildItem(recorder.initialize(config));
+ public LogConsoleFormatBuildItem setUpFormatter(
+ GoogleCloudJsonLoggingRecorder recorder, GoogleCloudJsonLoggingConfiguration configuration) {
+ return new LogConsoleFormatBuildItem(recorder.initialize(configuration));
}
}
diff --git a/examples/quarkus/pom.xml b/examples/quarkus/pom.xml
index 2eeeb40..6e4f042 100644
--- a/examples/quarkus/pom.xml
+++ b/examples/quarkus/pom.xml
@@ -14,7 +14,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<parent>
<groupId>eu.mulk.quarkus-googlecloud-jsonlogging</groupId>
<artifactId>quarkus-googlecloud-jsonlogging-parent</artifactId>
- <version>4.0.0</version>
+ <version>5.0.0</version>
</parent>
<artifactId>quarkus-googlecloud-jsonlogging-quarkus-example</artifactId>
diff --git a/examples/quarkus/src/main/resources/application.properties b/examples/quarkus/src/main/resources/application.properties
index 8b991a7..24eae27 100644
--- a/examples/quarkus/src/main/resources/application.properties
+++ b/examples/quarkus/src/main/resources/application.properties
@@ -1,3 +1,5 @@
# SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
#
-# SPDX-License-Identifier: GPL-3.0-or-later \ No newline at end of file
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+quarkus.log.console.google = true
diff --git a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingConfiguration.java b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingConfiguration.java
new file mode 100644
index 0000000..21a4ca9
--- /dev/null
+++ b/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleCloudJsonLoggingConfiguration.java
@@ -0,0 +1,22 @@
+// SPDX-FileCopyrightText: © 2022 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
+//
+// SPDX-License-Identifier: LGPL-3.0-or-later
+
+package eu.mulk.quarkus.googlecloud.jsonlogging.runtime;
+
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+/** Configuration for console logging in Google Cloud Logging JSON format. */
+@ConfigRoot(prefix = "quarkus.log.console", name = "google", phase = ConfigPhase.RUN_TIME)
+public class GoogleCloudJsonLoggingConfiguration {
+
+ /**
+ * Whether to enable Google Cloud Logging JSON logging to <code>stdout</code>/<code>stderr</code>.
+ *
+ * <p>Replaces the regular plain-text format for console logs.
+ */
+ @ConfigItem(defaultValue = "true", name = ConfigItem.PARENT)
+ public boolean enabled;
+}
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 8bdb308..af09231 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,7 +10,6 @@ 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;
@@ -27,8 +26,9 @@ public class GoogleCloudJsonLoggingRecorder {
*
* @return the registered {@link Formatter}.
*/
- public RuntimeValue<Optional<java.util.logging.Formatter>> initialize(GoogleJsonLogConfig config) {
- if(!config.jsonGoogle.enable) {
+ public RuntimeValue<Optional<java.util.logging.Formatter>> initialize(
+ GoogleCloudJsonLoggingConfiguration configuration) {
+ if (!configuration.enabled) {
return new RuntimeValue<>(Optional.empty());
}
@@ -41,5 +41,4 @@ 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
deleted file mode 100644
index b73b0bc..0000000
--- a/runtime/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/runtime/GoogleJsonLogConfig.java
+++ /dev/null
@@ -1,28 +0,0 @@
-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