-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add log messages if the reports are disabled or dry run enabled
Signed-off-by: Andru Stefanescu <als209@cam.ac.uk>
- Loading branch information
Showing
5 changed files
with
99 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
jgiven-core/src/test/java/com/tngtech/jgiven/impl/JGivenAppenderImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.tngtech.jgiven.impl; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.log4j.AppenderSkeleton; | ||
import org.apache.log4j.Level; | ||
import org.apache.log4j.spi.LoggingEvent; | ||
import org.apache.logging.log4j.core.config.plugins.Plugin; | ||
|
||
@Plugin(name = "JGivenAppender", category="Core", elementType="appender", printObject=true) | ||
public final class JGivenAppenderImpl extends AppenderSkeleton { | ||
private static final List<LoggingEvent> loggingEvents = new ArrayList<>(); | ||
|
||
@Override | ||
protected void append(LoggingEvent event) { | ||
loggingEvents.add(event); | ||
} | ||
|
||
@Override | ||
public void close() { } | ||
|
||
@Override | ||
public boolean requiresLayout() { | ||
return false; | ||
} | ||
|
||
static void resetEvents() { | ||
loggingEvents.clear(); | ||
} | ||
|
||
static boolean containsLoggingEvent(String logMessage, Level logLevel) { | ||
return loggingEvents.stream().anyMatch(loggingEvent -> loggingEvent.getMessage().equals(logMessage) && loggingEvent.getLevel().equals(logLevel)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
log4j.rootLogger=ERROR, stdout | ||
packages=com.tngtech.jgiven.impl | ||
log4j.rootLogger=ERROR, stdout, jgivenAppender | ||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n | ||
|
||
log4j.appender.jgivenAppender=com.tngtech.jgiven.impl.JGivenAppenderImpl | ||
log4j.appender.jgivenAppender.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.jgivenAppender.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n | ||
|
||
log4j.logger.com.tngtech.jgiven=INFO | ||
log4j.logger.com.tngtech.jgiven.impl.ScenarioExecutor=OFF |