diff --git a/deployment/src/test/java/io/quarkus/logging/sentry/SentryLoggerEnabledTest.java b/deployment/src/test/java/io/quarkus/logging/sentry/SentryLoggerEnabledTest.java new file mode 100644 index 0000000..e6e16c4 --- /dev/null +++ b/deployment/src/test/java/io/quarkus/logging/sentry/SentryLoggerEnabledTest.java @@ -0,0 +1,29 @@ +package io.quarkus.logging.sentry; + +import static io.quarkus.logging.sentry.SentryLoggerTest.getSentryHandler; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.logging.Handler; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.sentry.Sentry; + +public class SentryLoggerEnabledTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .setAllowTestClassOutsideDeployment(true) + .withConfigurationResource("application-sentry-logger-enabled.properties"); + + @Test + public void sentryLoggerEnabledTest() { + //test enabling sentry using quarkus.log.sentry.enabled + final Handler sentryHandler = getSentryHandler(); + assertThat(sentryHandler).isNotNull(); + assertThat(Sentry.isEnabled()).isTrue(); + } + +} diff --git a/deployment/src/test/resources/application-sentry-logger-enabled.properties b/deployment/src/test/resources/application-sentry-logger-enabled.properties new file mode 100644 index 0000000..f0cbc5f --- /dev/null +++ b/deployment/src/test/resources/application-sentry-logger-enabled.properties @@ -0,0 +1,2 @@ +quarkus.log.sentry.enabled=true +quarkus.log.sentry.dsn=https://123@default.com/22222 \ No newline at end of file diff --git a/docs/modules/ROOT/pages/includes/quarkus-logging-sentry.adoc b/docs/modules/ROOT/pages/includes/quarkus-logging-sentry.adoc index 9d9dea7..d16cbbd 100644 --- a/docs/modules/ROOT/pages/includes/quarkus-logging-sentry.adoc +++ b/docs/modules/ROOT/pages/includes/quarkus-logging-sentry.adoc @@ -26,6 +26,22 @@ endif::add-copy-button-to-env-var[] |`false` +a| [[quarkus-logging-sentry_quarkus.log.sentry.enabled]]`link:#quarkus-logging-sentry_quarkus.log.sentry.enabled[quarkus.log.sentry.enabled]` + +[.description] +-- +Determine whether to enable the Sentry logging extension. + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_SENTRY_ENABLED+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_LOG_SENTRY_ENABLED+++` +endif::add-copy-button-to-env-var[] +--|boolean +| + + a| [[quarkus-logging-sentry_quarkus.log.sentry.dsn]]`link:#quarkus-logging-sentry_quarkus.log.sentry.dsn[quarkus.log.sentry.dsn]` [.description] diff --git a/runtime/src/main/java/io/quarkus/logging/sentry/SentryConfig.java b/runtime/src/main/java/io/quarkus/logging/sentry/SentryConfig.java index 48d9f7b..9f13106 100644 --- a/runtime/src/main/java/io/quarkus/logging/sentry/SentryConfig.java +++ b/runtime/src/main/java/io/quarkus/logging/sentry/SentryConfig.java @@ -22,6 +22,12 @@ public class SentryConfig { @ConfigItem(name = ConfigItem.PARENT) boolean enable; + /** + * Determine whether to enable the Sentry logging extension. + */ + @ConfigItem + public Optional enabled; + /** * Sentry DSN * diff --git a/runtime/src/main/java/io/quarkus/logging/sentry/SentryHandlerValueFactory.java b/runtime/src/main/java/io/quarkus/logging/sentry/SentryHandlerValueFactory.java index f7a5737..11b8a5c 100644 --- a/runtime/src/main/java/io/quarkus/logging/sentry/SentryHandlerValueFactory.java +++ b/runtime/src/main/java/io/quarkus/logging/sentry/SentryHandlerValueFactory.java @@ -25,7 +25,7 @@ public class SentryHandlerValueFactory { public RuntimeValue> create(final SentryConfig config) { - if (!config.enable) { + if (!config.enabled.orElse(config.enable)) { return new RuntimeValue<>(Optional.empty()); }