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 @Override
public String toString() { public String toString() {
StringBuilder stringBuilder = new StringBuilder("Facts {").append("\n"); StringBuilder stringBuilder = new StringBuilder("[");
for (Map.Entry<String, Object> fact : facts.entrySet()) { List<Map.Entry<String, Object>> entries = new ArrayList<>(facts.entrySet());
stringBuilder.append(format(" Fact { %s : %s }", fact.getKey(), String.valueOf(fact.getValue()))); for (int i = 0; i < entries.size(); i++) {
stringBuilder.append("\n"); 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(); return stringBuilder.toString();
} }
} }

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

Loading…
Cancel
Save