Added func to write line to both GUI and CLI logs

This commit is contained in:
cyian-1756 2018-09-11 04:32:46 -04:00
parent 3f84496084
commit 37bf287df1

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 dobuleLog(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);
dobuleLog("Can't find ripper for " + realURL, Color.RED);
}
}
}