mirror of
https://bitbucket.org/projectswg/lightspeed.git
synced 2026-01-16 23:04:40 -05:00
Added error log filtering
This commit is contained in:
@@ -45,7 +45,10 @@
|
||||
<Label fx:id="statusText" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||
<Label fx:id="startTimeText" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||
<Label fx:id="uptimeText" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
||||
<Button fx:id="logDownloadButton" GridPane.columnIndex="1" GridPane.rowIndex="7" text="Download" />
|
||||
<HBox GridPane.columnIndex="1" GridPane.rowIndex="7" spacing="5.0" >
|
||||
<Button fx:id="logDownloadButton" text="Download" />
|
||||
<ComboBox fx:id="logVerbosityComboBox" maxWidth="200" />
|
||||
</HBox>
|
||||
</GridPane>
|
||||
<TextArea fx:id="logTextArea" styleClass="log" editable="false" maxHeight="Infinity" VBox.vgrow="ALWAYS" />
|
||||
</VBox>
|
||||
|
||||
@@ -37,10 +37,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.projectswg.common.concurrency.PswgScheduledThreadPool;
|
||||
import com.projectswg.common.control.IntentManager;
|
||||
import com.projectswg.common.debug.Log;
|
||||
import com.projectswg.common.debug.Log.LogLevel;
|
||||
import com.projectswg.common.javafx.FXMLController;
|
||||
import com.projectswg.common.javafx.FXMLUtilities;
|
||||
import com.projectswg.common.utilities.TimeFormatUtilities;
|
||||
@@ -65,12 +68,15 @@ import javafx.util.StringConverter;
|
||||
public class DeploymentTab implements FXMLController {
|
||||
|
||||
private static final SharedDeploymentData NULL_DEPLOY = new SharedDeploymentData(Long.MAX_VALUE, null);
|
||||
private static final Pattern LOG_FILTER_PATTERN = Pattern.compile("^[^A-Z]*([A-Z]{1})[^\r\n]*$", Pattern.MULTILINE);
|
||||
|
||||
@FXML
|
||||
private Parent rootDeployment;
|
||||
@FXML
|
||||
private ComboBox<SharedDeploymentData> deploymentComboBox;
|
||||
@FXML
|
||||
private ComboBox<LogLevel> logVerbosityComboBox;
|
||||
@FXML
|
||||
private Label serverNameText;
|
||||
@FXML
|
||||
private Label buildIdText;
|
||||
@@ -126,6 +132,9 @@ public class DeploymentTab implements FXMLController {
|
||||
}
|
||||
});
|
||||
logDownloadButton.setOnAction(eh -> downloadLog());
|
||||
logVerbosityComboBox.setItems(FXCollections.observableArrayList(LogLevel.values()));
|
||||
logVerbosityComboBox.setValue(LogLevel.VERBOSE);
|
||||
logVerbosityComboBox.valueProperty().addListener((obs, prev, val) -> updateDeploymentDetails());
|
||||
IntentManager.getInstance().registerForIntent(InboundPacketIntent.class, ipi -> Platform.runLater(() -> updateDeploymentList(false)));
|
||||
this.frontend.getData().getSelectedServerProperty().addListener((val, prev, next) -> Platform.runLater(() -> updateDeploymentList(true)));
|
||||
updateDeploymentList(true);
|
||||
@@ -259,7 +268,8 @@ public class DeploymentTab implements FXMLController {
|
||||
double pos = logTextArea.getScrollTop();
|
||||
int anchor = logTextArea.getAnchor();
|
||||
int caret = logTextArea.getCaretPosition();
|
||||
logTextArea.setText(tail(selectedDeployment.getOutput(), 100));
|
||||
String output = filterLog(logVerbosityComboBox.getValue(), selectedDeployment.getOutput());
|
||||
logTextArea.setText(tail(output, 100));
|
||||
if (anchor != caret) {
|
||||
logTextArea.setScrollTop(pos);
|
||||
logTextArea.selectRange(anchor, caret);
|
||||
@@ -269,6 +279,44 @@ public class DeploymentTab implements FXMLController {
|
||||
}
|
||||
}
|
||||
|
||||
private String filterLog(LogLevel level, String log) {
|
||||
String line;
|
||||
Matcher m = LOG_FILTER_PATTERN.matcher(log);
|
||||
StringBuilder filtered = new StringBuilder();
|
||||
LogLevel lineLevel;
|
||||
String lineLevelStr;
|
||||
while (m.find()) {
|
||||
line = m.group(0);
|
||||
lineLevelStr = m.group(1);
|
||||
if (lineLevelStr.isEmpty()) {
|
||||
Log.w("Invalid line [EMPTYGROUP]: %s", line);
|
||||
continue;
|
||||
}
|
||||
lineLevel = getLogLevelFromCharacter(lineLevelStr.charAt(0));
|
||||
if (lineLevel.compareTo(level) >= 0)
|
||||
filtered.append(line + '\n');
|
||||
}
|
||||
return filtered.toString();
|
||||
}
|
||||
|
||||
private LogLevel getLogLevelFromCharacter(char c) {
|
||||
switch (c) {
|
||||
default:
|
||||
case 'V':
|
||||
return LogLevel.VERBOSE;
|
||||
case 'D':
|
||||
return LogLevel.DEBUG;
|
||||
case 'I':
|
||||
return LogLevel.INFO;
|
||||
case 'W':
|
||||
return LogLevel.WARN;
|
||||
case 'E':
|
||||
return LogLevel.ERROR;
|
||||
case 'A':
|
||||
return LogLevel.ASSERT;
|
||||
}
|
||||
}
|
||||
|
||||
private void downloadLog() {
|
||||
SharedDeploymentData selectedDeployment = frontend.getData().getSelectedDeployment();
|
||||
if (selectedDeployment == null || selectedDeployment.getStartTime() == 0) {
|
||||
|
||||
Reference in New Issue
Block a user