Skip to main content
Sign in
Snippets Groups Projects
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
No related branches found
No related tags found
4 merge requests!39Version 1.1.0,!35Version 1.0.0,!17Version 0.3.2,!8Version 0.3.1
Pipeline #9777 failed
aspect Configuration { aspect Configuration {
public static boolean ASTNode.loggingEnabledForReads = false; public static boolean ASTNode.loggingEnabledForReads = false;
public static boolean ASTNode.loggingEnabledForWrites = false; public static boolean ASTNode.loggingEnabledForWrites = false;
public static boolean ASTNode.loggingEnabledForIncremental = false;
public static TypeDecl ASTNode.rootNode; public static TypeDecl ASTNode.rootNode;
public static boolean ASTNode.usesMqtt; public static boolean ASTNode.usesMqtt;
public static boolean ASTNode.usesRest; public static boolean ASTNode.usesRest;
... ...
......
...@@ -25,6 +25,7 @@ public class Compiler extends AbstractCompiler { ...@@ -25,6 +25,7 @@ public class Compiler extends AbstractCompiler {
private BooleanOption optionVerbose; private BooleanOption optionVerbose;
private BooleanOption optionLogReads; private BooleanOption optionLogReads;
private BooleanOption optionLogWrites; private BooleanOption optionLogWrites;
private BooleanOption optionLogIncremental;
private static final String OPTION_PROTOCOL_MQTT = "mqtt"; private static final String OPTION_PROTOCOL_MQTT = "mqtt";
private static final String OPTION_PROTOCOL_REST = "rest"; private static final String OPTION_PROTOCOL_REST = "rest";
...@@ -175,6 +176,9 @@ public class Compiler extends AbstractCompiler { ...@@ -175,6 +176,9 @@ public class Compiler extends AbstractCompiler {
optionLogWrites = addOption( optionLogWrites = addOption(
new BooleanOption("logWrites", "Enable logging for every write.") new BooleanOption("logWrites", "Enable logging for every write.")
.defaultValue(false)); .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 { private RagConnect parseProgram(Collection<String> files) throws CompilerException {
...@@ -226,6 +230,7 @@ public class Compiler extends AbstractCompiler { ...@@ -226,6 +230,7 @@ public class Compiler extends AbstractCompiler {
ragConnect.additionalRelations().forEach(ragConnectGrammarPart::addDeclaration); ragConnect.additionalRelations().forEach(ragConnectGrammarPart::addDeclaration);
ASTNode.loggingEnabledForReads = optionLogReads.value(); ASTNode.loggingEnabledForReads = optionLogReads.value();
ASTNode.loggingEnabledForWrites = optionLogWrites.value(); ASTNode.loggingEnabledForWrites = optionLogWrites.value();
ASTNode.loggingEnabledForIncremental = optionLogIncremental.value();
// reuse "--incremental" option of JastAdd // reuse "--incremental" option of JastAdd
ASTNode.incrementalOptionActive = getConfiguration().incremental() && getConfiguration().traceFlush(); ASTNode.incrementalOptionActive = getConfiguration().incremental() && getConfiguration().traceFlush();
... ...
......
...@@ -92,9 +92,9 @@ aspect RagConnectObserver { ...@@ -92,9 +92,9 @@ aspect RagConnectObserver {
} }
void add(ConnectToken connectToken, ASTNode node, String attributeString, Runnable attributeCall) { void add(ConnectToken connectToken, ASTNode node, String attributeString, Runnable attributeCall) {
{{#loggingEnabledForWrites}} {{#loggingEnabledForIncremental}}
System.out.println("** observer add: " + node + " on " + attributeString); System.out.println("** observer add: " + node + " on " + attributeString);
{{/loggingEnabledForWrites}} {{/loggingEnabledForIncremental}}
observedNodes.add(new RagConnectObserverEntry(connectToken, node, attributeString, attributeCall)); observedNodes.add(new RagConnectObserverEntry(connectToken, node, attributeString, attributeCall));
} }
void remove(ConnectToken connectToken) { void remove(ConnectToken connectToken) {
...@@ -105,9 +105,9 @@ aspect RagConnectObserver { ...@@ -105,9 +105,9 @@ aspect RagConnectObserver {
oldReceiver.accept(event, node, attribute, params, value); oldReceiver.accept(event, node, attribute, params, value);
// react to INC_FLUSH_START and remember entry // react to INC_FLUSH_START and remember entry
if (event == ASTState.Trace.Event.INC_FLUSH_START && startEntry == null) { if (event == ASTState.Trace.Event.INC_FLUSH_START && startEntry == null) {
{{#loggingEnabledForWrites}} {{#loggingEnabledForIncremental}}
System.out.println("** observer start: " + node + " on " + attribute); System.out.println("** observer start: " + node + " on " + attribute);
{{/loggingEnabledForWrites}} {{/loggingEnabledForIncremental}}
startEntry = new RagConnectObserverStartEntry(node, attribute, value); startEntry = new RagConnectObserverStartEntry(node, attribute, value);
return; return;
} }
...@@ -121,9 +121,9 @@ aspect RagConnectObserver { ...@@ -121,9 +121,9 @@ aspect RagConnectObserver {
RagConnectObserverEntry[] entriesToProcess = entryQueue.toArray(new RagConnectObserverEntry[entryQueue.size()]); RagConnectObserverEntry[] entriesToProcess = entryQueue.toArray(new RagConnectObserverEntry[entryQueue.size()]);
entryQueue.clear(); entryQueue.clear();
startEntry = null; startEntry = null;
{{#loggingEnabledForWrites}} {{#loggingEnabledForIncremental}}
System.out.println("** observer process (" + entriesToProcess.length + "): " + node + " on " + attribute); System.out.println("** observer process (" + entriesToProcess.length + "): " + node + " on " + attribute);
{{/loggingEnabledForWrites}} {{/loggingEnabledForIncremental}}
for (RagConnectObserverEntry entry : entriesToProcess) { for (RagConnectObserverEntry entry : entriesToProcess) {
entry.attributeCall.run(); entry.attributeCall.run();
} }
...@@ -135,16 +135,16 @@ aspect RagConnectObserver { ...@@ -135,16 +135,16 @@ aspect RagConnectObserver {
return; return;
} }
{{#loggingEnabledForWrites}} {{#loggingEnabledForIncremental}}
System.out.println("** observer check INC_FLUSH_ATTR event: " + node + " on " + attribute); 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. // iterate through list, if matching pair. could maybe be more efficient.
for (RagConnectObserverEntry entry : observedNodes) { for (RagConnectObserverEntry entry : observedNodes) {
if (entry.node.equals(node) && entry.attributeString.equals(attribute)) { if (entry.node.equals(node) && entry.attributeString.equals(attribute)) {
// hit. call the attribute/nta-token // hit. call the attribute/nta-token
{{#loggingEnabledForWrites}} {{#loggingEnabledForIncremental}}
System.out.println("** observer hit: " + entry.node + " on " + entry.attributeString); System.out.println("** observer hit: " + entry.node + " on " + entry.attributeString);
{{/loggingEnabledForWrites}} {{/loggingEnabledForIncremental}}
entryQueue.add(entry); entryQueue.add(entry);
} }
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment