Commit d54ce223 authored by René Schöne's avatar René Schöne
Browse files

add new cmdline argument to configure incremental logging output

parent c89ec543
Pipeline #9777 failed with stages
in 9 minutes and 25 seconds
aspect Configuration {
public static boolean ASTNode.loggingEnabledForReads = false;
public static boolean ASTNode.loggingEnabledForWrites = false;
public static boolean ASTNode.loggingEnabledForIncremental = false;
public static TypeDecl ASTNode.rootNode;
public static boolean ASTNode.usesMqtt;
public static boolean ASTNode.usesRest;
......
......@@ -25,6 +25,7 @@ public class Compiler extends AbstractCompiler {
private BooleanOption optionVerbose;
private BooleanOption optionLogReads;
private BooleanOption optionLogWrites;
private BooleanOption optionLogIncremental;
private static final String OPTION_PROTOCOL_MQTT = "mqtt";
private static final String OPTION_PROTOCOL_REST = "rest";
......@@ -175,6 +176,9 @@ public class Compiler extends AbstractCompiler {
optionLogWrites = addOption(
new BooleanOption("logWrites", "Enable logging for every write.")
.defaultValue(false));
optionLogIncremental = addOption(
new BooleanOption("logIncremental", "Enable logging for observer in incremental dependency tracking.")
.defaultValue(false));
}
private RagConnect parseProgram(Collection<String> files) throws CompilerException {
......@@ -226,6 +230,7 @@ public class Compiler extends AbstractCompiler {
ragConnect.additionalRelations().forEach(ragConnectGrammarPart::addDeclaration);
ASTNode.loggingEnabledForReads = optionLogReads.value();
ASTNode.loggingEnabledForWrites = optionLogWrites.value();
ASTNode.loggingEnabledForIncremental = optionLogIncremental.value();
// reuse "--incremental" option of JastAdd
ASTNode.incrementalOptionActive = getConfiguration().incremental() && getConfiguration().traceFlush();
......
......@@ -92,9 +92,9 @@ aspect RagConnectObserver {
}
void add(ConnectToken connectToken, ASTNode node, String attributeString, Runnable attributeCall) {
{{#loggingEnabledForWrites}}
{{#loggingEnabledForIncremental}}
System.out.println("** observer add: " + node + " on " + attributeString);
{{/loggingEnabledForWrites}}
{{/loggingEnabledForIncremental}}
observedNodes.add(new RagConnectObserverEntry(connectToken, node, attributeString, attributeCall));
}
void remove(ConnectToken connectToken) {
......@@ -105,9 +105,9 @@ aspect RagConnectObserver {
oldReceiver.accept(event, node, attribute, params, value);
// react to INC_FLUSH_START and remember entry
if (event == ASTState.Trace.Event.INC_FLUSH_START && startEntry == null) {
{{#loggingEnabledForWrites}}
{{#loggingEnabledForIncremental}}
System.out.println("** observer start: " + node + " on " + attribute);
{{/loggingEnabledForWrites}}
{{/loggingEnabledForIncremental}}
startEntry = new RagConnectObserverStartEntry(node, attribute, value);
return;
}
......@@ -121,9 +121,9 @@ aspect RagConnectObserver {
RagConnectObserverEntry[] entriesToProcess = entryQueue.toArray(new RagConnectObserverEntry[entryQueue.size()]);
entryQueue.clear();
startEntry = null;
{{#loggingEnabledForWrites}}
{{#loggingEnabledForIncremental}}
System.out.println("** observer process (" + entriesToProcess.length + "): " + node + " on " + attribute);
{{/loggingEnabledForWrites}}
{{/loggingEnabledForIncremental}}
for (RagConnectObserverEntry entry : entriesToProcess) {
entry.attributeCall.run();
}
......@@ -135,16 +135,16 @@ aspect RagConnectObserver {
return;
}
{{#loggingEnabledForWrites}}
{{#loggingEnabledForIncremental}}
System.out.println("** observer check INC_FLUSH_ATTR event: " + node + " on " + attribute);
{{/loggingEnabledForWrites}}
{{/loggingEnabledForIncremental}}
// iterate through list, if matching pair. could maybe be more efficient.
for (RagConnectObserverEntry entry : observedNodes) {
if (entry.node.equals(node) && entry.attributeString.equals(attribute)) {
// hit. call the attribute/nta-token
{{#loggingEnabledForWrites}}
{{#loggingEnabledForIncremental}}
System.out.println("** observer hit: " + entry.node + " on " + entry.attributeString);
{{/loggingEnabledForWrites}}
{{/loggingEnabledForIncremental}}
entryQueue.add(entry);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment