fix frozen packetlogger by giving option to skip big packets in logger (auto-enabled & with indication)

This commit is contained in:
sirjonasxx 2018-11-05 23:25:19 +01:00
parent 4154e935bc
commit 0d7c7b07ef
3 changed files with 23 additions and 4 deletions

View File

@ -26,6 +26,7 @@ public class UiLoggerController implements Initializable {
public CheckMenuItem chkDisplayStructure; public CheckMenuItem chkDisplayStructure;
public Label lblAutoScrolll; public Label lblAutoScrolll;
public CheckMenuItem chkAutoscroll; public CheckMenuItem chkAutoscroll;
public CheckMenuItem chkSkipBigPackets;
private StyleClassedTextArea area; private StyleClassedTextArea area;
@ -33,6 +34,8 @@ public class UiLoggerController implements Initializable {
private boolean viewOutgoing = true; private boolean viewOutgoing = true;
private boolean displayStructure = true; private boolean displayStructure = true;
private boolean autoScroll = true; private boolean autoScroll = true;
private boolean skiphugepackets = true;
private volatile boolean initialized = false; private volatile boolean initialized = false;
private final List<Element> appendLater = new ArrayList<>(); private final List<Element> appendLater = new ArrayList<>();
@ -78,16 +81,27 @@ public class UiLoggerController implements Initializable {
elements.add(new Element("]", "incoming")); elements.add(new Element("]", "incoming"));
elements.add(new Element(" <- ", "")); elements.add(new Element(" <- ", ""));
elements.add(new Element(packet.toString(), "incoming")); if (skiphugepackets && packet.length() > 8000) {
elements.add(new Element("<packet skipped>", "skipped"));
}
else {
elements.add(new Element(packet.toString(), "incoming"));
}
} else { } else {
elements.add(new Element("Outgoing[", "outgoing")); elements.add(new Element("Outgoing[", "outgoing"));
elements.add(new Element(String.valueOf(packet.headerId()), "")); elements.add(new Element(String.valueOf(packet.headerId()), ""));
elements.add(new Element("]", "outgoing")); elements.add(new Element("]", "outgoing"));
elements.add(new Element(" -> ", "")); elements.add(new Element(" -> ", ""));
elements.add(new Element(packet.toString(), "outgoing"));
if (skiphugepackets && packet.length() > 8000) {
elements.add(new Element("<packet skipped>", "skipped"));
}
else {
elements.add(new Element(packet.toString(), "outgoing"));
}
} }
if (!expr.equals("") && displayStructure) if (!expr.equals("") && displayStructure && (!skiphugepackets || packet.length() <= 8000))
elements.add(new Element("\n" + expr, "structure")); elements.add(new Element("\n" + expr, "structure"));
elements.add(new Element("\n--------------------\n", "")); elements.add(new Element("\n--------------------\n", ""));
@ -146,6 +160,10 @@ public class UiLoggerController implements Initializable {
autoScroll = !autoScroll; autoScroll = !autoScroll;
lblAutoScrolll.setText("Autoscroll: " + (autoScroll ? "True" : "False")); lblAutoScrolll.setText("Autoscroll: " + (autoScroll ? "True" : "False"));
} }
public void toggleSkipPackets(ActionEvent actionEvent) {
skiphugepackets = !skiphugepackets;
}
} }
class Element { class Element {

View File

@ -30,6 +30,7 @@
<accelerator> <accelerator>
<KeyCodeCombination alt="UP" code="L" control="DOWN" meta="UP" shift="UP" shortcut="UP" /> <KeyCodeCombination alt="UP" code="L" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></CheckMenuItem> </accelerator></CheckMenuItem>
<CheckMenuItem fx:id="chkSkipBigPackets" mnemonicParsing="false" onAction="#toggleSkipPackets" selected="true" text="Skip big packets" />
</Menu> </Menu>
</MenuBar> </MenuBar>
</top> </top>

View File

@ -15,7 +15,7 @@
-fx-fill: #0066cc; -fx-fill: #0066cc;
} }
.structure { .structure, .skipped {
-fx-fill: cyan; -fx-fill: cyan;
} }