Skip to content

Commit

Permalink
Use Logger instead of system.out and avoid Debug messages from ArchUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Schmidt committed Mar 9, 2022
1 parent 1cc5678 commit ebbdf3b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.tngtech.archunit.lang.ArchCondition;
import com.tngtech.archunit.lang.ConditionEvents;
import com.tngtech.archunit.lang.SimpleConditionEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -19,6 +21,8 @@

public class PurenessArchCondition extends ArchCondition<JavaClass> {

private final Logger log = LoggerFactory.getLogger(PurenessArchCondition.class);

private final PureDataStore dataStore;
//TODO KSC 20.02.22: Just protocols each checked code unit. Is this field still of use?
private final HashMap<String, JavaCodeUnit> ANALYSE_HELPER;
Expand Down Expand Up @@ -190,12 +194,11 @@ private void logViolation(ConditionEvents conditionEvents, JavaClass owner, Stri

@Override
public void finish(ConditionEvents conditionEvents) {
System.out.println(dataStore.info() + " Anzahl offene Interfaces: " + interfaces.size());
log.info(dataStore.info() + " Anzahl offene Interfaces: " + interfaces.size());
boolean hasChanged = true;
while (hasChanged) {
hasChanged = applyPropagationRules(conditionEvents);
//TODO KSC 14.02.22: Use a logger
System.out.println(dataStore.info() + " Anzahl offene Interfaces: " + interfaces.size());
log.info(dataStore.info() + " Anzahl offene Interfaces: " + interfaces.size());
}
dataStore.getAllMethodsOfClassification(PurenessClassification.UNSURE).forEach(un -> logUnsure(conditionEvents, un.getOwner(), un));
}
Expand Down
12 changes: 12 additions & 0 deletions functional-code-demo-test/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT"/>
</root>
<logger name="com.tngtech.archunit" level="warn"/>
</configuration>

0 comments on commit ebbdf3b

Please sign in to comment.