Skip to content

Commit

Permalink
Configure test logging globally for all subprojects. (#407)
Browse files Browse the repository at this point in the history
```
org.metafacture.flowcontrol.ObjectExceptionCatcherTest > shouldCatchException STANDARD_ERROR
    [Test worker] ERROR org.metafacture.flowcontrol.ObjectExceptionCatcher - 'Exception Message' while processing object: data

org.metafacture.flowcontrol.ObjectThreaderTest > shouldSplitAllObjectsToAllThreadedDownStreamReceivers STANDARD_ERROR
    [Test worker] INFO org.metafacture.flowcontrol.ObjectThreader - Adding thread 1
    [Test worker] INFO org.metafacture.flowcontrol.ObjectThreader - Adding thread 2

org.metafacture.json.JsonDecoderTest > testShouldProcessRecordsInArrayRoot STANDARD_ERROR
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

org.metafacture.monitoring.StreamLoggerTest > shouldActAsSinkIfNoReceiverIsSet STANDARD_ERROR
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - start record 1
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - start entity entity
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - literal literal=value
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - end entity
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - end record
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - resetStream
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - closeStream

org.metafacture.monitoring.StreamLoggerTest > shouldForwardAllReceivedEvents STANDARD_ERROR
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - start record 1
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - start entity entity
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - literal literal=value
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - end entity
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - end record
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - resetStream
    [Test worker] DEBUG org.metafacture.monitoring.StreamLogger - closeStream

org.metafacture.monitoring.ObjectTimerTest > testShouldHandleImmediateCloseStreamWithNoProcessing STANDARD_ERROR
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Executions: 0; Cumulative duration: 0s; Average duration: 0s
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Time to close stream:  14µs 965ns

org.metafacture.monitoring.ObjectTimerTest > testShouldMeasureExecutionTime STANDARD_ERROR
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 1: 150ms 138µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 2: 20ms 82µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 3: 30ms 130µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 4: 202ms 164µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Executions: 4; Cumulative duration: 402ms 515µs; Average duration: 100ms 629µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Time to close stream:  6µs 170ns

org.metafacture.monitoring.StreamTimerTest > testShouldHandleImmediateCloseStreamWithNoProcessing STANDARD_ERROR
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Executions: 0; Cumulative duration: 0s; Average duration: 0s
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Time to close stream:  1µs 470ns

org.metafacture.monitoring.StreamTimerTest > testShouldMeasureExecutionTime STANDARD_ERROR
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 1: 150ms 242µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 2: 20ms 149µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 3: 30ms 123µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Execution 4: 202ms 170µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Executions: 4; Cumulative duration: 402ms 685µs; Average duration: 100ms 671µs
    [Test worker] INFO org.metafacture.monitoring.TimerBase - Time to close stream:  5µs 111ns

org.metafacture.metamorph.test.validators.StreamValidatorTest > shouldFailIfEndRecordEventIsMissing STANDARD_ERROR
    [Test worker] INFO org.metafacture.metamorph.test.validators.StreamValidator - Event Stream: 1{}
```
  • Loading branch information
blackwinter committed Nov 6, 2021
1 parent 00533c5 commit aa21e39
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 43 deletions.
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions metafacture-biblio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,3 @@ dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.5.5'
}

test {
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public final class ObjectExceptionCatcher<T> extends

private String logPrefix;
private boolean logStackTrace;
private boolean logExceptionMessage = true;

/**
* Creates an instance of {@link ObjectExceptionCatcher} without a log message
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void setup() {
.when(exceptionThrowingModule).process(anyString());
exceptionCatcher = new ObjectExceptionCatcher<>();
exceptionCatcher.setReceiver(exceptionThrowingModule);
exceptionCatcher.setLogExceptionMessage(false);
}

@Test
Expand Down
1 change: 1 addition & 0 deletions metafacture-json/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
7 changes: 0 additions & 7 deletions metafacture-mangling/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,3 @@ dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.5.5'
}

test {
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}
7 changes: 0 additions & 7 deletions metafacture-triples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,3 @@ dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.5.5'
}

test {
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}
7 changes: 0 additions & 7 deletions metafacture-xml/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
7 changes: 0 additions & 7 deletions metafacture-yaml/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,3 @@ dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.5.5'
}

test {
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}
7 changes: 0 additions & 7 deletions metamorph/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,3 @@ sourceSets {
output.resourcesDir = sourceSets.test.java.outputDir
}
}

test {
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}

0 comments on commit aa21e39

Please sign in to comment.