diff --git a/build.gradle b/build.gradle index c6c82cda8..8e497d8fd 100644 --- a/build.gradle +++ b/build.gradle @@ -104,6 +104,15 @@ subprojects { checkstyleTest.enabled = false } + test { + systemProperties['org.slf4j.simpleLogger.defaultLogLevel'] = 'warn' + + testLogging { + showStandardStreams = true + exceptionFormat = 'full' + } + } + signing { required { scmInfo.isRelease() && gradle.taskGraph.hasTask(tasks.uploadArchives) diff --git a/metafacture-biblio/build.gradle b/metafacture-biblio/build.gradle index 87bbff635..7faf64733 100644 --- a/metafacture-biblio/build.gradle +++ b/metafacture-biblio/build.gradle @@ -31,10 +31,3 @@ dependencies { testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.5.5' } - -test { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } -} diff --git a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectExceptionCatcher.java b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectExceptionCatcher.java index 9bf50f748..c9b2f0421 100644 --- a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectExceptionCatcher.java +++ b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectExceptionCatcher.java @@ -52,6 +52,7 @@ public final class ObjectExceptionCatcher extends private String logPrefix; private boolean logStackTrace; + private boolean logExceptionMessage = true; /** * Creates an instance of {@link ObjectExceptionCatcher} without a log message @@ -108,13 +109,19 @@ public boolean isLogStackTrace() { return logStackTrace; } + /*package-private*/ void setLogExceptionMessage(final boolean logExceptionMessage) { + this.logExceptionMessage = logExceptionMessage; + } + @Override public void process(final T obj) { try { getReceiver().process(obj); } catch (final Exception e) { // checkstyle-disable-line IllegalCatch - LOG.error("{}'{}' while processing object: {}", logPrefix, e.getMessage(), obj); + if (logExceptionMessage) { + LOG.error("{}'{}' while processing object: {}", logPrefix, e.getMessage(), obj); + } if (logStackTrace) { final StringWriter stackTraceWriter = new StringWriter(); diff --git a/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectExceptionCatcherTest.java b/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectExceptionCatcherTest.java index 48e016e3a..3dd3681a8 100644 --- a/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectExceptionCatcherTest.java +++ b/metafacture-flowcontrol/src/test/java/org/metafacture/flowcontrol/ObjectExceptionCatcherTest.java @@ -45,6 +45,7 @@ public void setup() { .when(exceptionThrowingModule).process(anyString()); exceptionCatcher = new ObjectExceptionCatcher<>(); exceptionCatcher.setReceiver(exceptionThrowingModule); + exceptionCatcher.setLogExceptionMessage(false); } @Test diff --git a/metafacture-json/build.gradle b/metafacture-json/build.gradle index dd63d0eca..ea49dabfa 100644 --- a/metafacture-json/build.gradle +++ b/metafacture-json/build.gradle @@ -24,4 +24,5 @@ dependencies { implementation 'com.jayway.jsonpath:json-path:2.6.0' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.5.5' + testRuntimeOnly 'org.slf4j:slf4j-simple:1.7.21' } diff --git a/metafacture-mangling/build.gradle b/metafacture-mangling/build.gradle index d77bc17d2..ed003d105 100644 --- a/metafacture-mangling/build.gradle +++ b/metafacture-mangling/build.gradle @@ -23,10 +23,3 @@ dependencies { testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.5.5' } - -test { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } -} diff --git a/metafacture-triples/build.gradle b/metafacture-triples/build.gradle index e8d5966c1..821d2e18a 100644 --- a/metafacture-triples/build.gradle +++ b/metafacture-triples/build.gradle @@ -24,10 +24,3 @@ dependencies { testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.5.5' } - -test { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } -} diff --git a/metafacture-xml/build.gradle b/metafacture-xml/build.gradle index 7949ccd4d..c91c82c8e 100644 --- a/metafacture-xml/build.gradle +++ b/metafacture-xml/build.gradle @@ -26,10 +26,3 @@ dependencies { testImplementation 'org.mockito:mockito-core:2.5.5' testRuntimeOnly 'org.slf4j:slf4j-simple:1.7.21' } - -test { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } -} diff --git a/metafacture-yaml/build.gradle b/metafacture-yaml/build.gradle index 097cdb676..293fa37c5 100644 --- a/metafacture-yaml/build.gradle +++ b/metafacture-yaml/build.gradle @@ -23,10 +23,3 @@ dependencies { testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.5.5' } - -test { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } -} diff --git a/metamorph/build.gradle b/metamorph/build.gradle index ed537f1a5..a14f783d3 100644 --- a/metamorph/build.gradle +++ b/metamorph/build.gradle @@ -39,10 +39,3 @@ sourceSets { output.resourcesDir = sourceSets.test.java.outputDir } } - -test { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } -}