Better debug output
This commit is contained in:
parent
4bb28c3f39
commit
6219a6bfc9
@ -28,6 +28,9 @@ import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.Time;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -84,6 +87,7 @@ public class Utils {
|
||||
|
||||
public void println(int level) {
|
||||
if (StaticVars.outputLevel >= level) {
|
||||
final String time = getTimeString();
|
||||
if (StaticVars.outputLevel == 0) {
|
||||
System.out.println();
|
||||
} else {
|
||||
@ -94,10 +98,11 @@ public class Utils {
|
||||
|
||||
public void println(int level, String str) {
|
||||
if (StaticVars.outputLevel >= level) {
|
||||
final String time = getTimeString();
|
||||
if (StaticVars.outputLevel == 0) {
|
||||
System.out.println(str);
|
||||
System.out.println("[" + time + "]"+str);
|
||||
} else {
|
||||
System.err.println(str);
|
||||
System.err.println("[" + time + "]"+str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,6 +117,41 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public void println(int level, String prefix, String str) {
|
||||
if (StaticVars.outputLevel >= level) {
|
||||
final String time = getTimeString();
|
||||
if (StaticVars.outputLevel == 0) {
|
||||
System.out.println("[" + time + "][" + prefix + "]" + str);
|
||||
} else {
|
||||
System.err.println("[" + time + "][" + prefix + "]" + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void println(int level, String... parts) {
|
||||
if (StaticVars.outputLevel >= level) {
|
||||
final String time = getTimeString();
|
||||
String output = "";
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
if (i + 1 == parts.length) {
|
||||
output += parts[i];
|
||||
} else {
|
||||
output += "[" + parts[i] + "]";
|
||||
}
|
||||
}
|
||||
if (StaticVars.outputLevel == 0) {
|
||||
System.out.println("[" + time + "]" + output);
|
||||
} else {
|
||||
|
||||
System.err.println("[" + time + "]" + output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getTimeString() {
|
||||
return LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss.SSS"));
|
||||
}
|
||||
|
||||
int before = 0;
|
||||
boolean due = false;
|
||||
|
||||
|
@ -35,15 +35,21 @@ public class MathSolver {
|
||||
public ObjectArrayList<ObjectArrayList<Function>> solveAllSteps() throws InterruptedException, Error {
|
||||
ObjectArrayList<ObjectArrayList<Function>> steps = new ObjectArrayList<>();
|
||||
ObjectArrayList<Function> lastFnc = null, currFnc = new ObjectArrayList<>();
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Solving all steps. Input: " + initialFunction.toString());
|
||||
currFnc.add(initialFunction);
|
||||
long debugStepNumber = 0;
|
||||
int stepBefore = 0, stepAfter = 0;
|
||||
do {
|
||||
final String stepName = "Step " + debugStepNumber;
|
||||
for (int i = stepBefore; i <= stepAfter; i++) {
|
||||
lastFnc = lastFunctions[i] = currFnc;
|
||||
}
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Starting step. Input: " + currFnc);
|
||||
stepBefore = stepState;
|
||||
ObjectArrayList<Function> stepResult = solveStep(lastFnc);
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Step state: "+stepStates[stepState]+", Consecutive null steps: " + consecutiveNullSteps + ", currentStepStateN: " + currentStepStateN + ", result: ");
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step state: " + stepStates[stepState]);
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result: " + stepResult);
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result details: Consecutive steps that did nothing: " + consecutiveNullSteps + ", this step did " + currentStepStateN + " simplifications.");
|
||||
if (stepResult == null) {
|
||||
currFnc = lastFnc;
|
||||
} else {
|
||||
@ -54,6 +60,7 @@ public class MathSolver {
|
||||
steps.add(currFnc);
|
||||
}
|
||||
stepAfter = stepState;
|
||||
debugStepNumber++;
|
||||
} while(consecutiveNullSteps < stepStates.length && !checkEquals(currFnc, lastFunctions[stepState]));
|
||||
return steps;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user