Unify gui/console logging
This commit is contained in:
parent
78c3b6917d
commit
fd1f5b17f4
|
@ -1,7 +1,5 @@
|
|||
|
||||
package net.filebot.ui.rename;
|
||||
|
||||
|
||||
import static net.filebot.Logging.*;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
@ -23,7 +21,6 @@ import javax.swing.text.JTextComponent;
|
|||
import net.filebot.util.ui.AbstractFancyListCellRenderer;
|
||||
import net.filebot.util.ui.SwingUI;
|
||||
|
||||
|
||||
class HighlightListCellRenderer extends AbstractFancyListCellRenderer {
|
||||
|
||||
protected final JTextComponent textComponent = new JTextField();
|
||||
|
@ -31,7 +28,6 @@ class HighlightListCellRenderer extends AbstractFancyListCellRenderer {
|
|||
protected final Pattern pattern;
|
||||
protected final Highlighter.HighlightPainter highlightPainter;
|
||||
|
||||
|
||||
public HighlightListCellRenderer(Pattern pattern, Highlighter.HighlightPainter highlightPainter, int padding) {
|
||||
super(new Insets(0, 0, 0, 0));
|
||||
|
||||
|
@ -50,7 +46,6 @@ class HighlightListCellRenderer extends AbstractFancyListCellRenderer {
|
|||
textComponent.getDocument().addDocumentListener(new HighlightUpdateListener());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
@ -58,7 +53,6 @@ class HighlightListCellRenderer extends AbstractFancyListCellRenderer {
|
|||
textComponent.setText(value.toString());
|
||||
}
|
||||
|
||||
|
||||
protected void updateHighlighter() {
|
||||
textComponent.getHighlighter().removeAllHighlights();
|
||||
|
||||
|
@ -69,12 +63,11 @@ class HighlightListCellRenderer extends AbstractFancyListCellRenderer {
|
|||
textComponent.getHighlighter().addHighlight(matcher.start(0), matcher.end(0), highlightPainter);
|
||||
} catch (BadLocationException e) {
|
||||
// should not happen
|
||||
debug.log(Level.SEVERE, e.toString(), e);
|
||||
debug.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setForeground(Color fg) {
|
||||
super.setForeground(fg);
|
||||
|
@ -85,7 +78,6 @@ class HighlightListCellRenderer extends AbstractFancyListCellRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private class HighlightUpdateListener implements DocumentListener {
|
||||
|
||||
@Override
|
||||
|
@ -93,13 +85,11 @@ class HighlightListCellRenderer extends AbstractFancyListCellRenderer {
|
|||
updateHighlighter();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
updateHighlighter();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
updateHighlighter();
|
||||
|
|
|
@ -65,7 +65,7 @@ class MatchAction extends AbstractAction {
|
|||
// display progress dialog and stop blocking EDT
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.SEVERE, e.toString(), e);
|
||||
debug.log(Level.SEVERE, e.getMessage(), e);
|
||||
} finally {
|
||||
window.setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class MatchAction extends AbstractAction {
|
|||
// insert objects that could not be matched at the end of the model
|
||||
model.addAll(matcher.remainingValues(), matcher.remainingCandidates());
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.SEVERE, e.toString(), e);
|
||||
debug.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -272,7 +272,7 @@ public class RenamePanel extends JComponent {
|
|||
UserFiles.revealFiles(list.getSelectedValuesList());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.getMessage());
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
} finally {
|
||||
getWindow(evt.getSource()).setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ public class RenamePanel extends JComponent {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.getMessage());
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -388,7 +388,7 @@ public class RenamePanel extends JComponent {
|
|||
Preset p = (Preset) JsonReader.jsonToJava(it);
|
||||
actionPopup.add(new ApplyPresetAction(p));
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.toString());
|
||||
debug.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
actionPopup.addSeparator();
|
||||
|
@ -590,7 +590,7 @@ public class RenamePanel extends JComponent {
|
|||
try {
|
||||
initMode = Mode.valueOf(persistentLastFormatState.getValue());
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.getMessage());
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package net.filebot.ui.rename;
|
||||
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.Logging.*;
|
||||
import static net.filebot.Settings.*;
|
||||
|
@ -37,7 +35,6 @@ import javax.swing.text.BadLocationException;
|
|||
import net.filebot.ResourceManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
|
||||
class ValidateDialog extends JDialog {
|
||||
|
||||
private final JList list;
|
||||
|
@ -46,7 +43,6 @@ class ValidateDialog extends JDialog {
|
|||
|
||||
private boolean cancelled = true;
|
||||
|
||||
|
||||
public ValidateDialog(Window owner, Collection<File> source) {
|
||||
super(owner, "Invalid Names", ModalityType.DOCUMENT_MODAL);
|
||||
|
||||
|
@ -74,7 +70,7 @@ class ValidateDialog extends JDialog {
|
|||
textComponent.getHighlighter().addHighlight(matcher.start(0), matcher.end(0), highlightPainter);
|
||||
} catch (BadLocationException e) {
|
||||
// should not happen
|
||||
debug.log(Level.SEVERE, e.toString(), e);
|
||||
debug.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,17 +97,14 @@ class ValidateDialog extends JDialog {
|
|||
pack();
|
||||
}
|
||||
|
||||
|
||||
public List<File> getModel() {
|
||||
return unmodifiableList(Arrays.asList(model));
|
||||
}
|
||||
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
|
||||
private void finish(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
|
||||
|
@ -156,7 +149,6 @@ class ValidateDialog extends JDialog {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
public static boolean validate(Component parent, List<File> source) {
|
||||
IndexView<File> invalidFilePaths = new IndexView<File>(source);
|
||||
|
||||
|
@ -193,24 +185,20 @@ class ValidateDialog extends JDialog {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static class IndexView<E> extends AbstractList<E> {
|
||||
|
||||
private final List<Integer> mapping = new ArrayList<Integer>();
|
||||
|
||||
private final List<E> source;
|
||||
|
||||
|
||||
public IndexView(List<E> source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
public boolean addIndex(int index) {
|
||||
return mapping.add(index);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
int sourceIndex = mapping.get(index);
|
||||
|
@ -221,13 +209,11 @@ class ValidateDialog extends JDialog {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
return source.set(mapping.get(index), element);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mapping.size();
|
||||
|
|
|
@ -785,7 +785,7 @@ class SubtitleAutoMatchDialog extends JDialog {
|
|||
throw e;
|
||||
} catch (Exception e) {
|
||||
// log and ignore
|
||||
debug.log(Level.WARNING, e.getMessage());
|
||||
debug.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -376,7 +376,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
|||
// logout from test session
|
||||
osdb.logout();
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.toString());
|
||||
debug.warning(e.getMessage());
|
||||
}
|
||||
});
|
||||
} else if (osdbUser.getText().isEmpty()) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.awt.Cursor;
|
|||
import java.io.File;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.event.CellEditorListener;
|
||||
|
@ -86,7 +85,7 @@ class MovieEditor implements TableCellEditor {
|
|||
|
||||
// print error message
|
||||
if (error != null) {
|
||||
debug.log(Level.WARNING, error.toString());
|
||||
debug.warning(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ public class FileTransferable implements Transferable {
|
|||
files.add(file);
|
||||
} catch (Throwable e) {
|
||||
// URISyntaxException, IllegalArgumentException, FileNotFoundException, LinkageError, etc
|
||||
debug.log(Level.WARNING, "Invalid file URI: " + line);
|
||||
debug.warning("Invalid file URI: " + line);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class SaveAction extends AbstractAction {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.SEVERE, e.toString(), e);
|
||||
debug.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package net.filebot.ui.transfer;
|
||||
|
||||
|
||||
import static net.filebot.Logging.*;
|
||||
|
||||
import java.awt.datatransfer.Transferable;
|
||||
|
@ -11,15 +9,12 @@ import java.util.logging.Level;
|
|||
import javax.swing.TransferHandler;
|
||||
import javax.swing.TransferHandler.TransferSupport;
|
||||
|
||||
|
||||
public abstract class TransferablePolicy {
|
||||
|
||||
public abstract boolean accept(Transferable tr) throws Exception;
|
||||
|
||||
|
||||
public abstract void handleTransferable(Transferable tr, TransferAction action) throws Exception;
|
||||
|
||||
|
||||
public boolean canImport(TransferSupport support) {
|
||||
if (support.isDrop()) {
|
||||
support.setShowDropLocation(false);
|
||||
|
@ -34,12 +29,11 @@ public abstract class TransferablePolicy {
|
|||
// just assume that the transferable will be accepted, accept will be called in importData again anyway
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.toString(), e);
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean importData(TransferSupport support) {
|
||||
Transferable transferable = support.getTransferable();
|
||||
|
||||
|
@ -49,14 +43,13 @@ public abstract class TransferablePolicy {
|
|||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.toString(), e);
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
|
||||
// transferable was not accepted, or transfer failed
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protected TransferAction getTransferAction(TransferSupport support) {
|
||||
if (support.isDrop()) {
|
||||
return TransferAction.fromDnDConstant(support.getDropAction());
|
||||
|
@ -66,25 +59,19 @@ public abstract class TransferablePolicy {
|
|||
return TransferAction.PUT;
|
||||
}
|
||||
|
||||
|
||||
public static enum TransferAction {
|
||||
PUT(TransferHandler.MOVE),
|
||||
ADD(TransferHandler.COPY),
|
||||
LINK(TransferHandler.LINK);
|
||||
PUT(TransferHandler.MOVE), ADD(TransferHandler.COPY), LINK(TransferHandler.LINK);
|
||||
|
||||
private final int dndConstant;
|
||||
|
||||
|
||||
private TransferAction(int dndConstant) {
|
||||
this.dndConstant = dndConstant;
|
||||
}
|
||||
|
||||
|
||||
public int getDnDConstant() {
|
||||
return dndConstant;
|
||||
}
|
||||
|
||||
|
||||
public static TransferAction fromDnDConstant(int dndConstant) {
|
||||
for (TransferAction action : values()) {
|
||||
if (dndConstant == action.dndConstant)
|
||||
|
|
|
@ -42,7 +42,6 @@ import java.util.Scanner;
|
|||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -67,7 +66,7 @@ public final class FileUtilities {
|
|||
try {
|
||||
return Files.move(source.toPath(), destination.toPath(), StandardCopyOption.ATOMIC_MOVE).toFile();
|
||||
} catch (AtomicMoveNotSupportedException e) {
|
||||
debug.log(Level.WARNING, e.toString());
|
||||
debug.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ public class PreferencesMap<T> implements Map<String, T> {
|
|||
try {
|
||||
prefs.flush();
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.toString());
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,20 +34,16 @@ public abstract class Timer implements Runnable {
|
|||
addShutdownHook();
|
||||
} catch (Exception e) {
|
||||
// may fail if running with restricted permissions
|
||||
debug.log(Level.WARNING, e.getClass().getName() + ": " + e.getMessage());
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
|
||||
// remove shutdown hook after execution
|
||||
runnable = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
runnable = () -> {
|
||||
try {
|
||||
Timer.this.run();
|
||||
} finally {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
try {
|
||||
|
@ -55,7 +51,7 @@ public abstract class Timer implements Runnable {
|
|||
removeShutdownHook();
|
||||
} catch (Exception e) {
|
||||
// may fail if running with restricted permissions
|
||||
debug.log(Level.WARNING, e.getClass().getName() + ": " + e.getMessage());
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public class LinkButton extends JButton {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
debug.log(Level.SEVERE, e.toString(), e);
|
||||
debug.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ public class AcoustIDClient implements MusicIdentificationService {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e.toString(), e);
|
||||
debug.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
@ -279,7 +278,7 @@ public final class WebRequest {
|
|||
try {
|
||||
return Charset.forName(matcher.group(1));
|
||||
} catch (IllegalArgumentException e) {
|
||||
debug.log(Level.WARNING, "Illegal charset: " + contentType);
|
||||
debug.warning("Illegal charset: " + contentType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue