diff options
Diffstat (limited to 'runtime')
3 files changed, 25 insertions, 32 deletions
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 |