polish logs

pull/130/merge
Mahmoud Ben Hassine 7 years ago
parent f9a96a075f
commit 6f3e05e96d

@ -95,12 +95,16 @@ public class Facts implements Iterable<Map.Entry<String, Object>> {
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder("Facts {").append("\n");
for (Map.Entry<String, Object> fact : facts.entrySet()) {
stringBuilder.append(format(" Fact { %s : %s }", fact.getKey(), String.valueOf(fact.getValue())));
stringBuilder.append("\n");
StringBuilder stringBuilder = new StringBuilder("[");
List<Map.Entry<String, Object>> entries = new ArrayList<>(facts.entrySet());
for (int i = 0; i < entries.size(); i++) {
Map.Entry<String, Object> entry = entries.get(i);
stringBuilder.append(format(" { %s : %s } ", entry.getKey(), String.valueOf(entry.getValue())));
if (i < entries.size() - 1) {
stringBuilder.append(",");
}
}
stringBuilder.append("}");
stringBuilder.append("]");
return stringBuilder.toString();
}
}

@ -105,12 +105,12 @@ public final class InferenceRulesEngine implements RulesEngine {
public void fire(Rules rules, Facts facts) {
Set<Rule> selectedRules;
do {
LOGGER.info("Selecting candidate rules based on the following {}", facts);
LOGGER.info("Selecting candidate rules based on the following facts: {}", facts);
selectedRules = selectCandidates(rules, facts);
if(!selectedRules.isEmpty()) {
delegate.doFire(new Rules(selectedRules), facts);
} else {
LOGGER.info("No candidate rules found for {}", facts);
LOGGER.info("No candidate rules found for facts: {}", facts);
}
} while (!selectedRules.isEmpty());
}

Loading…
Cancel
Save