Changed logger to LOGGER

This commit is contained in:
Gaboso 2018-06-04 22:58:14 -04:00
parent ccaa2edeb0
commit bc63f14fd3

View File

@ -66,7 +66,7 @@ import javax.swing.UnsupportedLookAndFeelException;
*/ */
public final class MainWindow implements Runnable, RipStatusHandler { public final class MainWindow implements Runnable, RipStatusHandler {
private static final Logger logger = Logger.getLogger(MainWindow.class); private static final Logger LOGGER = Logger.getLogger(MainWindow.class);
private boolean isRipping = false; // Flag to indicate if we're ripping something private boolean isRipping = false; // Flag to indicate if we're ripping something
@ -279,7 +279,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
try { try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException | IllegalAccessException e) { } catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException | IllegalAccessException e) {
logger.error("[!] Exception setting system theme:", e); LOGGER.error("[!] Exception setting system theme:", e);
} }
ripTextfield = new JTextField("", 20); ripTextfield = new JTextField("", 20);
@ -821,7 +821,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
try { try {
chosenPath = chosenFile.getCanonicalPath(); chosenPath = chosenFile.getCanonicalPath();
} catch (Exception e) { } catch (Exception e) {
logger.error("Error while getting selected path: ", e); LOGGER.error("Error while getting selected path: ", e);
return; return;
} }
configSaveDirLabel.setText(Utils.shortenPath(chosenPath)); configSaveDirLabel.setText(Utils.shortenPath(chosenPath));
@ -877,7 +877,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
break; break;
} }
Logger.getRootLogger().setLevel(newLevel); Logger.getRootLogger().setLevel(newLevel);
logger.setLevel(newLevel); LOGGER.setLevel(newLevel);
ConsoleAppender ca = (ConsoleAppender)Logger.getRootLogger().getAppender("stdout"); ConsoleAppender ca = (ConsoleAppender)Logger.getRootLogger().getAppender("stdout");
if (ca != null) { if (ca != null) {
ca.setThreshold(newLevel); ca.setThreshold(newLevel);
@ -951,7 +951,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
try { try {
Desktop.getDesktop().browse(URI.create("http://github.com/ripmeapp/ripme")); Desktop.getDesktop().browse(URI.create("http://github.com/ripmeapp/ripme"));
} catch (IOException e) { } catch (IOException e) {
logger.error("Exception while opening project home page", e); LOGGER.error("Exception while opening project home page", e);
} }
} }
}); });
@ -1024,10 +1024,10 @@ public final class MainWindow implements Runnable, RipStatusHandler {
HISTORY.clear(); HISTORY.clear();
if (historyFile.exists()) { if (historyFile.exists()) {
try { try {
logger.info(rb.getString("loading.history.from") + " " + historyFile.getCanonicalPath()); LOGGER.info(rb.getString("loading.history.from") + " " + historyFile.getCanonicalPath());
HISTORY.fromFile(historyFile.getCanonicalPath()); HISTORY.fromFile(historyFile.getCanonicalPath());
} catch (IOException e) { } catch (IOException e) {
logger.error("Failed to load history from file " + historyFile, e); LOGGER.error("Failed to load history from file " + historyFile, e);
JOptionPane.showMessageDialog(null, JOptionPane.showMessageDialog(null,
"RipMe failed to load the history file at " + historyFile.getAbsolutePath() + "\n\n" + "RipMe failed to load the history file at " + historyFile.getAbsolutePath() + "\n\n" +
"Error: " + e.getMessage() + "\n\n" + "Error: " + e.getMessage() + "\n\n" +
@ -1037,7 +1037,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }
} else { } else {
logger.info(rb.getString("loading.history.from.configuration")); LOGGER.info(rb.getString("loading.history.from.configuration"));
HISTORY.fromList(Utils.getConfigList("download.history")); HISTORY.fromList(Utils.getConfigList("download.history"));
if (HISTORY.toList().isEmpty()) { if (HISTORY.toList().isEmpty()) {
// Loaded from config, still no entries. // Loaded from config, still no entries.
@ -1067,7 +1067,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
HISTORY.toFile(historyFile.toString()); HISTORY.toFile(historyFile.toString());
Utils.setConfigList("download.history", Collections.emptyList()); Utils.setConfigList("download.history", Collections.emptyList());
} catch (IOException e) { } catch (IOException e) {
logger.error("Failed to save history to file " + historyFile, e); LOGGER.error("Failed to save history to file " + historyFile, e);
} }
} }
@ -1089,7 +1089,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
try { try {
Thread.sleep(500); Thread.sleep(500);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
logger.error(rb.getString("interrupted.while.waiting.to.rip.next.album"), ie); LOGGER.error(rb.getString("interrupted.while.waiting.to.rip.next.album"), ie);
} }
ripNextAlbum(); ripNextAlbum();
} else { } else {
@ -1113,7 +1113,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
try { try {
url = new URL(urlString); url = new URL(urlString);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
logger.error("[!] Could not generate URL for '" + urlString + "'", e); LOGGER.error("[!] Could not generate URL for '" + urlString + "'", e);
error("Given URL is not valid, expecting http://website.com/page/..."); error("Given URL is not valid, expecting http://website.com/page/...");
return null; return null;
} }
@ -1128,7 +1128,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
ripper.setup(); ripper.setup();
} catch (Exception e) { } catch (Exception e) {
failed = true; failed = true;
logger.error("Could not find ripper for URL " + url, e); LOGGER.error("Could not find ripper for URL " + url, e);
error(e.getMessage()); error(e.getMessage());
} }
if (!failed) { if (!failed) {
@ -1146,7 +1146,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
} }
return t; return t;
} catch (Exception e) { } catch (Exception e) {
logger.error("[!] Error while ripping: " + e.getMessage(), e); LOGGER.error("[!] Error while ripping: " + e.getMessage(), e);
error("Unable to rip this URL: " + e.getMessage()); error("Unable to rip this URL: " + e.getMessage());
} }
} }
@ -1197,28 +1197,28 @@ public final class MainWindow implements Runnable, RipStatusHandler {
switch(msg.getStatus()) { switch(msg.getStatus()) {
case LOADING_RESOURCE: case LOADING_RESOURCE:
case DOWNLOAD_STARTED: case DOWNLOAD_STARTED:
if (logger.isEnabledFor(Level.INFO)) { if (LOGGER.isEnabledFor(Level.INFO)) {
appendLog("Downloading " + msg.getObject(), Color.BLACK); appendLog("Downloading " + msg.getObject(), Color.BLACK);
} }
break; break;
case DOWNLOAD_COMPLETE: case DOWNLOAD_COMPLETE:
if (logger.isEnabledFor(Level.INFO)) { if (LOGGER.isEnabledFor(Level.INFO)) {
appendLog("Downloaded " + msg.getObject(), Color.GREEN); appendLog("Downloaded " + msg.getObject(), Color.GREEN);
} }
break; break;
case DOWNLOAD_ERRORED: case DOWNLOAD_ERRORED:
if (logger.isEnabledFor(Level.ERROR)) { if (LOGGER.isEnabledFor(Level.ERROR)) {
appendLog((String) msg.getObject(), Color.RED); appendLog((String) msg.getObject(), Color.RED);
} }
break; break;
case DOWNLOAD_WARN: case DOWNLOAD_WARN:
if (logger.isEnabledFor(Level.WARN)) { if (LOGGER.isEnabledFor(Level.WARN)) {
appendLog((String) msg.getObject(), Color.ORANGE); appendLog((String) msg.getObject(), Color.ORANGE);
} }
break; break;
case RIP_ERRORED: case RIP_ERRORED:
if (logger.isEnabledFor(Level.ERROR)) { if (LOGGER.isEnabledFor(Level.ERROR)) {
appendLog((String) msg.getObject(), Color.RED); appendLog((String) msg.getObject(), Color.RED);
} }
stopButton.setEnabled(false); stopButton.setEnabled(false);
@ -1270,7 +1270,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
try { try {
Desktop.getDesktop().open(new File(event.getActionCommand())); Desktop.getDesktop().open(new File(event.getActionCommand()));
} catch (Exception e) { } catch (Exception e) {
logger.error(e); LOGGER.error(e);
} }
}); });
pack(); pack();
@ -1341,7 +1341,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
Utils.setConfigInteger("window.y", y); Utils.setConfigInteger("window.y", y);
Utils.setConfigInteger("window.w", w); Utils.setConfigInteger("window.w", w);
Utils.setConfigInteger("window.h", h); Utils.setConfigInteger("window.h", h);
logger.debug("Saved window position (x=" + x + ", y=" + y + ", w=" + w + ", h=" + h + ")"); LOGGER.debug("Saved window position (x=" + x + ", y=" + y + ", w=" + w + ", h=" + h + ")");
} }
private static void restoreWindowPosition(Frame frame) { private static void restoreWindowPosition(Frame frame) {
@ -1356,7 +1356,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
int w = Utils.getConfigInteger("window.w", -1); int w = Utils.getConfigInteger("window.w", -1);
int h = Utils.getConfigInteger("window.h", -1); int h = Utils.getConfigInteger("window.h", -1);
if (x < 0 || y < 0 || w <= 0 || h <= 0) { if (x < 0 || y < 0 || w <= 0 || h <= 0) {
logger.debug("UNUSUAL: One or more of: x, y, w, or h was still less than 0 after reading config"); LOGGER.debug("UNUSUAL: One or more of: x, y, w, or h was still less than 0 after reading config");
mainFrame.setLocationRelativeTo(null); // default to middle of screen mainFrame.setLocationRelativeTo(null); // default to middle of screen
return; return;
} }