Logger enhancements
UI shows already-downloaded files as 'completed' instead of 'errored'. No more "Retrieving" lines in UI log window. WARN log levels all around. Mostly for #147
This commit is contained in:
parent
dd55cd1b43
commit
083cd8d7cc
@ -198,7 +198,7 @@ public abstract class AbstractRipper
|
|||||||
* @param url
|
* @param url
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public abstract void downloadProblem(URL url, String message);
|
public abstract void downloadExists(URL url, File file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Number of files downloaded.
|
* @return Number of files downloaded.
|
||||||
|
@ -125,14 +125,14 @@ public abstract class AlbumRipper extends AbstractRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadProblem(URL url, String message) {
|
public void downloadExists(URL url, File file) {
|
||||||
if (observer == null) {
|
if (observer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemsPending.remove(url);
|
itemsPending.remove(url);
|
||||||
itemsErrored.put(url, message);
|
itemsCompleted.put(url, file);
|
||||||
observer.update(this, new RipStatusMessage(STATUS.DOWNLOAD_WARN, url + " : " + message));
|
observer.update(this, new RipStatusMessage(STATUS.DOWNLOAD_WARN, url + " already saved as " + file.getAbsolutePath()));
|
||||||
|
|
||||||
checkIfComplete();
|
checkIfComplete();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class DownloadFileThread extends Thread {
|
|||||||
saveAs.delete();
|
saveAs.delete();
|
||||||
} else {
|
} else {
|
||||||
logger.info("[!] Skipping " + url + " -- file already exists: " + prettySaveAs);
|
logger.info("[!] Skipping " + url + " -- file already exists: " + prettySaveAs);
|
||||||
observer.downloadProblem(url, "File already exists: " + prettySaveAs);
|
observer.downloadExists(url, saveAs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class DownloadVideoThread extends Thread {
|
|||||||
saveAs.delete();
|
saveAs.delete();
|
||||||
} else {
|
} else {
|
||||||
logger.info("[!] Skipping " + url + " -- file already exists: " + prettySaveAs);
|
logger.info("[!] Skipping " + url + " -- file already exists: " + prettySaveAs);
|
||||||
observer.downloadProblem(url, "File already exists: " + prettySaveAs);
|
observer.downloadExists(url, saveAs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,11 +111,11 @@ public abstract class VideoRipper extends AbstractRipper {
|
|||||||
checkIfComplete();
|
checkIfComplete();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void downloadProblem(URL url, String message) {
|
public void downloadExists(URL url, File file) {
|
||||||
if (observer == null) {
|
if (observer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
observer.update(this, new RipStatusMessage(STATUS.DOWNLOAD_WARN, url + " : " + message));
|
observer.update(this, new RipStatusMessage(STATUS.DOWNLOAD_WARN, url + " already saved as " + file));
|
||||||
checkIfComplete();
|
checkIfComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ import javax.swing.text.SimpleAttributeSet;
|
|||||||
import javax.swing.text.StyleConstants;
|
import javax.swing.text.StyleConstants;
|
||||||
import javax.swing.text.StyledDocument;
|
import javax.swing.text.StyledDocument;
|
||||||
|
|
||||||
|
import org.apache.log4j.Level;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractRipper;
|
import com.rarchives.ripme.ripper.AbstractRipper;
|
||||||
@ -139,6 +140,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private static AbstractRipper ripper;
|
private static AbstractRipper ripper;
|
||||||
|
|
||||||
public MainWindow() {
|
public MainWindow() {
|
||||||
|
Logger.getRootLogger().setLevel(Level.ERROR);
|
||||||
mainFrame = new JFrame("RipMe v" + UpdateUtils.getThisJarVersion());
|
mainFrame = new JFrame("RipMe v" + UpdateUtils.getThisJarVersion());
|
||||||
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
mainFrame.setResizable(false);
|
mainFrame.setResizable(false);
|
||||||
@ -1021,20 +1023,26 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
switch(msg.getStatus()) {
|
switch(msg.getStatus()) {
|
||||||
case LOADING_RESOURCE:
|
case LOADING_RESOURCE:
|
||||||
case DOWNLOAD_STARTED:
|
case DOWNLOAD_STARTED:
|
||||||
appendLog( "Downloading: " + (String) msg.getObject(), Color.BLACK);
|
if (logger.isEnabledFor(Level.INFO)) {
|
||||||
|
appendLog( "Downloading " + (String) msg.getObject(), Color.BLACK);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD_COMPLETE:
|
case DOWNLOAD_COMPLETE:
|
||||||
appendLog( "Completed: " + (String) msg.getObject(), Color.GREEN);
|
appendLog( "Downloaded " + (String) msg.getObject(), Color.GREEN);
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD_ERRORED:
|
case DOWNLOAD_ERRORED:
|
||||||
appendLog( "Error: " + (String) msg.getObject(), Color.RED);
|
if (logger.isEnabledFor(Level.ERROR)) {
|
||||||
|
appendLog((String) msg.getObject(), Color.RED);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD_WARN:
|
case DOWNLOAD_WARN:
|
||||||
appendLog( "Warn: " + (String) msg.getObject(), Color.ORANGE);
|
appendLog((String) msg.getObject(), Color.ORANGE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIP_ERRORED:
|
case RIP_ERRORED:
|
||||||
appendLog( "Error: " + (String) msg.getObject(), Color.RED);
|
if (logger.isEnabledFor(Level.ERROR)) {
|
||||||
|
appendLog((String) msg.getObject(), Color.RED);
|
||||||
|
}
|
||||||
stopButton.setEnabled(false);
|
stopButton.setEnabled(false);
|
||||||
statusProgress.setValue(0);
|
statusProgress.setValue(0);
|
||||||
statusProgress.setVisible(false);
|
statusProgress.setVisible(false);
|
||||||
@ -1079,7 +1087,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
Image folderIcon = ImageIO.read(getClass().getClassLoader().getResource("folder.png"));
|
Image folderIcon = ImageIO.read(getClass().getClassLoader().getResource("folder.png"));
|
||||||
openButton.setIcon(new ImageIcon(folderIcon));
|
openButton.setIcon(new ImageIcon(folderIcon));
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
appendLog( "Rip complete, saved to " + prettyFile, Color.GREEN);
|
appendLog( "Rip complete, saved to " + f.getAbsolutePath(), Color.GREEN);
|
||||||
openButton.setActionCommand(f.toString());
|
openButton.setActionCommand(f.toString());
|
||||||
openButton.addActionListener(new ActionListener() {
|
openButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -333,6 +333,9 @@ public class Utils {
|
|||||||
PropertyConfigurator.configure(stream);
|
PropertyConfigurator.configure(stream);
|
||||||
}
|
}
|
||||||
logger.info("Loaded " + logFile);
|
logger.info("Loaded " + logFile);
|
||||||
|
try {
|
||||||
|
stream.close();
|
||||||
|
} catch (IOException e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
log4j.appender.FILE = org.apache.log4j.RollingFileAppender
|
log4j.appender.FILE = org.apache.log4j.RollingFileAppender
|
||||||
log4j.appender.FILE.File = ripme.log
|
log4j.appender.FILE.File = ripme.log
|
||||||
log4j.appender.FILE.ImmediateFlush = true
|
log4j.appender.FILE.ImmediateFlush = true
|
||||||
log4j.appender.FILE.Threshold = debug
|
log4j.appender.FILE.Threshold = warn
|
||||||
log4j.appender.FILE.maxFileSize = 20MB
|
log4j.appender.FILE.maxFileSize = 20MB
|
||||||
log4j.appender.FILE.layout = org.apache.log4j.PatternLayout
|
log4j.appender.FILE.layout = org.apache.log4j.PatternLayout
|
||||||
log4j.appender.FILE.layout.ConversionPattern = %d %-4r [%t] %-5p %c{2} %x - %m%n
|
log4j.appender.FILE.layout.ConversionPattern = %d %-5p %c{2} %x - %m%n
|
||||||
|
|
||||||
# define the console appender
|
# define the console appender
|
||||||
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
||||||
log4j.appender.stdout.Target = System.out
|
log4j.appender.stdout.Target = System.out
|
||||||
log4j.appender.stdout.Threshold = info
|
log4j.appender.stdout.Threshold = warn
|
||||||
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
||||||
log4j.appender.stdout.layout.ConversionPattern = %m%n
|
log4j.appender.stdout.layout.ConversionPattern = %m%n
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user