1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-27 07:44:20 +02:00

Merge pull request #927 from cyian-1756/logFunc

Added func to write line to both GUI and CLI logs
This commit is contained in:
cyian-1756
2018-09-15 14:39:13 -04:00
committed by GitHub

View File

@@ -1053,6 +1053,12 @@ public final class MainWindow implements Runnable, RipStatusHandler {
}
}
/**
* Write a line to the Log section of the GUI
*
* @param text the string to log
* @param color the color of the line
*/
private void appendLog(final String text, final Color color) {
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setForeground(sas, color);
@@ -1066,6 +1072,17 @@ public final class MainWindow implements Runnable, RipStatusHandler {
logText.setCaretPosition(sd.getLength());
}
/**
* Write a line to the GUI log and the CLI log
*
* @param line the string to log
* @param color the color of the line for the GUI log
*/
public void displayAndLogError(String line, Color color) {
appendLog(line, color);
LOGGER.error(line);
}
private void loadHistory() {
File historyFile = new File(Utils.getConfigDir() + File.separator + "history.json");
HISTORY.clear();
@@ -1213,7 +1230,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
urlText = "http://" + urlText;
}
URL url = new URL(urlText);
// Ripper is needed here to throw.not throw an Exception
// Ripper is needed here to throw/not throw an Exception
AbstractRipper ripper = AbstractRipper.getRipper(url);
return true;
} catch (Exception e) {
@@ -1238,8 +1255,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
queueListModel.add(queueListModel.size(), realURL);
ripTextfield.setText("");
} else {
appendLog("Can't find ripper for " + realURL, Color.RED);
LOGGER.error("Can't find ripper for " + realURL);
displayAndLogError("Can't find ripper for " + realURL, Color.RED);
}
}
}