diff --git a/docs/pages/corefunctionality/configuration.rst b/docs/pages/corefunctionality/configuration.rst index 17fe4c95..572bf122 100644 --- a/docs/pages/corefunctionality/configuration.rst +++ b/docs/pages/corefunctionality/configuration.rst @@ -56,7 +56,7 @@ If you are developing behind a cooperate proxy, you can configure Hoverfly to us Logging ------- Hoverfly logs to SLF4J by default, meaning that you have control of Hoverfly logs using JAVA logging framework. -Here is an example ``logback.xml`` that directs Hoverfly WARN logs to the console: +Here is an example ``logback.xml`` that directs Hoverfly ``WARN`` logs to the console: .. code-block:: xml diff --git a/junit5/src/main/java/io/specto/hoverfly/junit5/HoverflyExtensionUtils.java b/junit5/src/main/java/io/specto/hoverfly/junit5/HoverflyExtensionUtils.java index a9142fae..81cf19be 100644 --- a/junit5/src/main/java/io/specto/hoverfly/junit5/HoverflyExtensionUtils.java +++ b/junit5/src/main/java/io/specto/hoverfly/junit5/HoverflyExtensionUtils.java @@ -31,7 +31,8 @@ static io.specto.hoverfly.junit.core.HoverflyConfig getHoverflyConfigs(HoverflyC configs = localConfigs() .sslCertificatePath(config.sslCertificatePath()) .sslKeyPath(config.sslKeyPath()) - .upstreamProxy(config.upstreamProxy()); + .upstreamProxy(config.upstreamProxy()) + .logLevel(config.logLevel()); if (config.plainHttpTunneling()) { ((LocalHoverflyConfig) configs).plainHttpTunneling(); } diff --git a/junit5/src/main/java/io/specto/hoverfly/junit5/api/HoverflyConfig.java b/junit5/src/main/java/io/specto/hoverfly/junit5/api/HoverflyConfig.java index 71a79a85..9b759970 100644 --- a/junit5/src/main/java/io/specto/hoverfly/junit5/api/HoverflyConfig.java +++ b/junit5/src/main/java/io/specto/hoverfly/junit5/api/HoverflyConfig.java @@ -3,6 +3,7 @@ import io.specto.hoverfly.junit.core.SimulationPreprocessor; import io.specto.hoverfly.junit.core.config.LocalHoverflyConfig; +import io.specto.hoverfly.junit.core.config.LogLevel; import io.specto.hoverfly.junit.core.config.RemoteHoverflyConfig; import java.lang.annotation.ElementType; @@ -92,4 +93,9 @@ * Set additional commands for starting Hoverfly */ String[] commands() default {}; + + /** + * Set Hoverfly log level + */ + LogLevel logLevel() default LogLevel.INFO; } diff --git a/junit5/src/test/java/io/specto/hoverfly/junit5/HoverflyConfigTest.java b/junit5/src/test/java/io/specto/hoverfly/junit5/HoverflyConfigTest.java index d76ec51e..10011c12 100644 --- a/junit5/src/test/java/io/specto/hoverfly/junit5/HoverflyConfigTest.java +++ b/junit5/src/test/java/io/specto/hoverfly/junit5/HoverflyConfigTest.java @@ -4,6 +4,7 @@ import io.specto.hoverfly.junit.core.HoverflyMode; import io.specto.hoverfly.junit.core.SimulationPreprocessor; import io.specto.hoverfly.junit.core.config.HoverflyConfiguration; +import io.specto.hoverfly.junit.core.config.LogLevel; import io.specto.hoverfly.junit.core.model.Simulation; import io.specto.hoverfly.junit5.api.HoverflyConfig; import io.specto.hoverfly.junit5.api.HoverflyCore; @@ -11,6 +12,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import java.util.Optional; + import static org.assertj.core.api.Assertions.assertThat; @@ -40,6 +43,7 @@ void shouldUseDefaultValues(Hoverfly hoverfly) { assertThat(configs.isStatefulCapture()).isFalse(); assertThat(configs.getSimulationPreprocessor()).isEmpty(); assertThat(configs.getCommands()).isEmpty(); + assertThat(configs.getLogLevel()).isEqualTo(Optional.of(LogLevel.INFO)); } } @@ -49,7 +53,8 @@ void shouldUseDefaultValues(Hoverfly hoverfly) { plainHttpTunneling = true, disableTlsVerification = true, upstreamProxy = "localhost:5000", webServer = true, statefulCapture = true, simulationPreprocessor = CustomSimulationPreprocessor.class, - commands = { "-log-level", "error" } + commands = { "-log-level", "error" }, + logLevel = LogLevel.DEBUG )) @ExtendWith(HoverflyExtension.class) class CustomizedSettings { @@ -69,6 +74,7 @@ void shouldUseCustomizedValues(Hoverfly hoverfly) { assertThat(configs.isStatefulCapture()).isTrue(); assertThat(configs.getSimulationPreprocessor()).isPresent(); assertThat(configs.getCommands()).containsExactly("-log-level", "error"); + assertThat(configs.getLogLevel()).isEqualTo(Optional.of(LogLevel.DEBUG)); } }