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) { private void appendLog(final String text, final Color color) {
SimpleAttributeSet sas = new SimpleAttributeSet(); SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setForeground(sas, color); StyleConstants.setForeground(sas, color);
@ -1066,6 +1072,17 @@ public final class MainWindow implements Runnable, RipStatusHandler {
logText.setCaretPosition(sd.getLength()); 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() { private void loadHistory() {
File historyFile = new File(Utils.getConfigDir() + File.separator + "history.json"); File historyFile = new File(Utils.getConfigDir() + File.separator + "history.json");
HISTORY.clear(); HISTORY.clear();
@ -1213,7 +1230,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
urlText = "http://" + urlText; urlText = "http://" + urlText;
} }
URL url = new URL(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); AbstractRipper ripper = AbstractRipper.getRipper(url);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
@ -1238,8 +1255,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
queueListModel.add(queueListModel.size(), realURL); queueListModel.add(queueListModel.size(), realURL);
ripTextfield.setText(""); ripTextfield.setText("");
} else { } else {
appendLog("Can't find ripper for " + realURL, Color.RED); dobuleLog("Can't find ripper for " + realURL, Color.RED);
LOGGER.error("Can't find ripper for " + realURL);
} }
} }
} }