Unify gui/console logging

This commit is contained in:
Reinhard Pointner 2016-03-09 16:02:36 +00:00
parent 63fd9d77af
commit 2f76465c38
21 changed files with 116 additions and 144 deletions

View File

@ -48,9 +48,9 @@ public final class Logging {
// print messages
out.print(getFormatter().format(record));
Throwable t = record.getThrown();
if (t != null) {
StackTraceUtils.deepSanitize(t).printStackTrace(out);
Throwable thrown = record.getThrown();
if (thrown != null) {
StackTraceUtils.deepSanitize(thrown).printStackTrace(out);
}
// flush every message immediately

View File

@ -1,6 +1,7 @@
package net.filebot;
import static java.awt.GraphicsEnvironment.*;
import static java.util.Arrays.*;
import static java.util.stream.Collectors.*;
import static javax.swing.JOptionPane.*;
import static net.filebot.Logging.*;
@ -14,6 +15,7 @@ import java.awt.Dialog.ModalityType;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
@ -30,7 +32,8 @@ import java.security.ProtectionDomain;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
import java.util.logging.StreamHandler;
import java.util.logging.XMLFormatter;
import javax.swing.JDialog;
import javax.swing.JFrame;
@ -48,6 +51,7 @@ import net.filebot.mac.MacAppUtilities;
import net.filebot.ui.FileBotMenuBar;
import net.filebot.ui.GettingStartedStage;
import net.filebot.ui.MainFrame;
import net.filebot.ui.NotificationLogging;
import net.filebot.ui.PanelBuilder;
import net.filebot.ui.SinglePanelFrame;
import net.filebot.ui.transfer.FileTransferable;
@ -86,7 +90,7 @@ public class Main {
if (args.clearCache()) {
log.info("Clear cache and temporary files");
for (File folder : getChildren(getApplicationFolder().getCanonicalFile(), FOLDERS)) {
log.config("* Delete " + folder);
log.info("* Delete " + folder);
delete(folder);
}
CacheManager.getInstance().clearAll();
@ -149,15 +153,7 @@ public class Main {
}
// GUI mode => start user interface
SwingUtilities.invokeAndWait(() -> {
try {
// use native laf an all platforms
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
Logger.getLogger(Main.class.getName()).log(Level.WARNING, e.getMessage(), e);
}
startUserInterface(args);
});
SwingUtilities.invokeAndWait(() -> startUserInterface(args));
// preload media.types (when loaded during DnD it will freeze the UI for a few hundred milliseconds)
MediaTypes.getDefault();
@ -191,14 +187,23 @@ public class Main {
}
private static void startUserInterface(ArgumentBean args) {
JFrame frame = null;
try {
// GUI logging settings
log.addHandler(new NotificationLogging(getApplicationName()));
log.addHandler(new StreamHandler(new FileOutputStream(new File(getApplicationFolder(), "error.log.xml"), true), new XMLFormatter()));
if (args.mode == null) {
// default frame
frame = new MainFrame(MainFrame.createPanelBuilders());
} else {
// single panel frame
PanelBuilder[] selection = Stream.of(MainFrame.createPanelBuilders()).filter(p -> p.getName().matches(args.mode)).toArray(PanelBuilder[]::new);
// use native LaF an all platforms
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
debug.log(Level.WARNING, e.getMessage(), e);
}
// default frame
JFrame frame = new MainFrame(MainFrame.createPanelBuilders());
// single panel frame
if (args.mode != null) {
PanelBuilder[] selection = stream(MainFrame.createPanelBuilders()).filter(p -> p.getName().matches(args.mode)).toArray(PanelBuilder[]::new);
if (selection.length == 1) {
frame = new SinglePanelFrame(selection[0]).publish(new FileTransferable(args.getFiles(false)));
} else if (selection.length > 1) {
@ -222,7 +227,7 @@ public class Main {
public void windowClosing(WindowEvent e) {
e.getWindow().setVisible(false);
// make sure any long running operations are done now and not later on the shutdownhook thread
// make sure any long running operations are done now and not later on the shutdown hook thread
HistorySpooler.getInstance().commit();
// show donation / review reminders to power users (more than 2000 renames)
@ -250,7 +255,8 @@ public class Main {
// Ubuntu specific configuration
String options = System.getenv("JAVA_TOOL_OPTIONS");
if (options != null && options.contains("jayatanaag.jar")) {
frame.setJMenuBar(FileBotMenuBar.createHelp()); // menu should be rendered via JAyatana on Ubuntu 15.04 and higher
// menu should be rendered via JAyatana on Ubuntu 15.04 and higher
frame.setJMenuBar(FileBotMenuBar.createHelp());
}
frame.setIconImages(ResourceManager.getApplicationIcons());
} else {

View File

@ -2,9 +2,9 @@ package net.filebot.mac;
import static java.util.Collections.*;
import static javax.swing.BorderFactory.*;
import static net.filebot.Logging.*;
import static net.filebot.UserFiles.*;
import static net.filebot.mac.MacAppUtilities.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -242,9 +242,9 @@ public class DropToUnlock extends JList<File> {
try {
String owner = Files.getOwner(f.toPath()).getName();
String permissions = PosixFilePermissions.toString(Files.getPosixFilePermissions(f.toPath()));
UILogger.severe(String.format("Permission denied: %s (%s %s)", f, permissions, owner));
log.severe(String.format("Permission denied: %s (%s %s)", f, permissions, owner));
} catch (Exception e) {
UILogger.severe(String.format("Permission denied: %s", f));
log.severe(String.format("Permission denied: %s", f));
}
});
}

View File

@ -1,7 +1,7 @@
package net.filebot.ui;
import static javax.swing.ScrollPaneConstants.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.Logging.*;
import static net.filebot.util.ui.SwingUI.*;
import java.awt.Dimension;
@ -207,7 +207,7 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
switch (results.size()) {
case 0:
UILogger.log(Level.WARNING, String.format("'%s' has not been found.", requestProcessor.request.getSearchText()));
log.log(Level.WARNING, String.format("'%s' has not been found.", requestProcessor.request.getSearchText()));
break;
case 1:
selectedSearchResult = results.iterator().next();
@ -231,7 +231,7 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
new FetchTask(requestProcessor).execute();
} catch (Exception e) {
tab.close();
UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
log.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
}
}
@ -277,12 +277,12 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
// close tab if no elements were fetched
if (get().size() <= 0) {
UILogger.warning(statusMessage);
log.warning(statusMessage);
tab.close();
}
} catch (Exception e) {
tab.close();
UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
log.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
} finally {
tab.setLoading(false);
}

View File

@ -4,8 +4,8 @@ import static java.awt.event.InputEvent.*;
import static java.awt.event.KeyEvent.*;
import static javax.swing.KeyStroke.*;
import static javax.swing.ScrollPaneConstants.*;
import static net.filebot.Logging.*;
import static net.filebot.Settings.*;
import static net.filebot.ui.NotificationLogging.*;
import java.awt.Color;
import java.awt.Cursor;
@ -114,7 +114,7 @@ public class MainFrame extends JFrame {
@Override
public void actionPerformed(ActionEvent e) {
CacheManager.getInstance().clearAll();
UILogger.info("Cache has been cleared");
log.info("Cache has been cleared");
}
});

View File

@ -1,114 +1,80 @@
package net.filebot.ui;
import static net.filebot.Settings.*;
import static net.filebot.util.ui.notification.Direction.*;
import java.awt.GraphicsEnvironment;
import java.util.logging.ConsoleHandler;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.SwingUtilities;
import net.filebot.ResourceManager;
import net.filebot.util.ExceptionUtilities;
import net.filebot.util.ui.notification.MessageNotification;
import net.filebot.util.ui.notification.NotificationManager;
import net.filebot.util.ui.notification.QueueNotificationLayout;
public class NotificationLogging extends Handler {
public static final Logger UILogger = createNotificationLogger("net.filebot.logger.ui");
private final String title;
private final int timeout;
private final NotificationManager manager;
private static Logger createNotificationLogger(String name) {
Logger log = Logger.getLogger(name);
// don't use parent handlers
log.setUseParentHandlers(false);
// ui handler
log.addHandler(new NotificationLogging());
// console handler (for warnings and errors only)
ConsoleHandler console = new ConsoleHandler();
console.setLevel(Level.WARNING);
log.addHandler(console);
return log;
public NotificationLogging(String title) {
this(title, 2500, new NotificationManager(new QueueNotificationLayout(NORTH, SOUTH)));
}
public final NotificationManager notificationManager;
public final int timeout = 2500;
public NotificationLogging(String title, int timeout, NotificationManager manager) {
this.title = title;
this.timeout = timeout;
this.manager = manager;
public NotificationLogging() {
this(new NotificationManager(new QueueNotificationLayout(NORTH, SOUTH)));
setFormatter(new NotificationFormatter());
setLevel(Level.INFO);
}
public NotificationLogging(NotificationManager notificationManager) {
this.notificationManager = notificationManager;
}
@Override
public void publish(LogRecord record) {
// fail gracefully on an headless machine
if (GraphicsEnvironment.isHeadless())
return;
final Level level = record.getLevel();
final String message = getMessage(record);
String message = getFormatter().format(record);
Level level = record.getLevel();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (level == Level.INFO) {
show(message, ResourceManager.getIcon("message.info"), timeout * 1);
} else if (level == Level.WARNING) {
show(message, ResourceManager.getIcon("message.warning"), timeout * 2);
} else if (level == Level.SEVERE) {
show(message, ResourceManager.getIcon("message.error"), timeout * 3);
}
SwingUtilities.invokeLater(() -> {
if (level == Level.INFO) {
show(message, ResourceManager.getIcon("message.info"), timeout * 1);
} else if (level == Level.WARNING) {
show(message, ResourceManager.getIcon("message.warning"), timeout * 2);
} else if (level == Level.SEVERE) {
show(message, ResourceManager.getIcon("message.error"), timeout * 3);
}
});
}
protected String getMessage(LogRecord record) {
String message = record.getMessage();
if ((message == null || message.isEmpty()) && record.getThrown() != null) {
// if message is empty, display exception string
return ExceptionUtilities.getMessage(record.getThrown());
}
return message;
}
protected void show(String message, Icon icon, int timeout) {
notificationManager.show(new MessageNotification(getApplicationName(), message, icon, timeout));
manager.show(new MessageNotification(title, message, icon, timeout));
}
@Override
public void close() throws SecurityException {
}
@Override
public void flush() {
}
public static class NotificationFormatter extends Formatter {
@Override
public String format(LogRecord record) {
return record.getMessage();
}
}
}

View File

@ -1,7 +1,7 @@
package net.filebot.ui.analyze;
import static net.filebot.Logging.*;
import static net.filebot.UserFiles.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.ExceptionUtilities.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -102,7 +102,7 @@ class ExtractTool extends Tool<TableModel> {
if (findCause(e, InterruptedException.class) != null) {
throw findCause(e, InterruptedException.class);
}
UILogger.log(Level.WARNING, e.getMessage(), e);
log.log(Level.WARNING, e.getMessage(), e);
}
return new ArchiveEntryModel(entries);
@ -297,7 +297,7 @@ class ExtractTool extends Tool<TableModel> {
archive.close();
}
} catch (Exception e) {
UILogger.log(Level.WARNING, "Failed to extract archive: " + file.getName(), e);
log.log(Level.WARNING, "Failed to extract archive: " + file.getName(), e);
}
if (isCancelled()) {

View File

@ -1,7 +1,7 @@
package net.filebot.ui.analyze;
import static net.filebot.Logging.*;
import static net.filebot.Settings.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -48,7 +48,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy<TreeNo
@Override
protected void process(Exception e) {
UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
log.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
}
@Override

View File

@ -2,8 +2,8 @@ package net.filebot.ui.list;
import static java.awt.Font.*;
import static java.lang.Math.*;
import static net.filebot.Logging.*;
import static net.filebot.media.MediaDetection.*;
import static net.filebot.ui.NotificationLogging.*;
import java.awt.BorderLayout;
import java.awt.Font;
@ -135,7 +135,7 @@ public class ListPanel extends JComponent {
list.getModel().clear();
list.getModel().addAll(names);
} catch (Exception e) {
UILogger.log(Level.WARNING, ExceptionUtilities.getMessage(e), e);
log.log(Level.WARNING, ExceptionUtilities.getMessage(e), e);
}
}
};

View File

@ -1,8 +1,8 @@
package net.filebot.ui.rename;
import static net.filebot.Logging.*;
import static net.filebot.MediaTypes.*;
import static net.filebot.UserFiles.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.ui.SwingUI.*;
import java.awt.Color;
@ -262,10 +262,10 @@ class BindingDialog extends JDialog {
// check episode and media file
if (getInfoObject() == null) {
// illegal episode string
UILogger.warning(String.format("Failed to parse episode: '%s'", infoTextField.getText()));
log.warning(String.format("Failed to parse episode: '%s'", infoTextField.getText()));
} else if (getMediaFile() == null && !mediaFileTextField.getText().isEmpty()) {
// illegal file path
UILogger.warning(String.format("Invalid media file: '%s'", mediaFileTextField.getText()));
log.warning(String.format("Invalid media file: '%s'", mediaFileTextField.getText()));
} else {
// everything seems to be in order
finish(true);
@ -304,7 +304,7 @@ class BindingDialog extends JDialog {
}
}
} catch (MediaInfoException e) {
UILogger.log(Level.SEVERE, e.getMessage(), e);
log.log(Level.SEVERE, e.getMessage(), e);
}
// could not retrieve media info

View File

@ -1,7 +1,7 @@
package net.filebot.ui.rename;
import static net.filebot.Logging.*;
import static net.filebot.MediaTypes.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.FileUtilities.*;
import java.awt.datatransfer.Transferable;
@ -112,7 +112,7 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy<File>
@Override
protected void process(Exception e) {
UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
log.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
}
}

View File

@ -3,8 +3,8 @@ package net.filebot.ui.rename;
import static java.awt.Font.*;
import static java.util.Collections.*;
import static javax.swing.BorderFactory.*;
import static net.filebot.Logging.*;
import static net.filebot.Settings.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.ExceptionUtilities.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -778,7 +778,7 @@ public class FormatDialog extends JDialog {
finish(true);
} catch (ScriptException e) {
UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e));
log.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e));
}
}
};

View File

@ -2,7 +2,7 @@ package net.filebot.ui.rename;
import static java.awt.Font.*;
import static javax.swing.BorderFactory.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.Logging.*;
import static net.filebot.util.ui.SwingUI.*;
import java.awt.Component;
@ -409,7 +409,7 @@ public class PresetEditor extends JDialog {
JComponent source = (JComponent) evt.getSource();
popup.show(source, -3, source.getHeight() + 4);
} catch (Exception e) {
UILogger.log(Level.WARNING, "Invalid preset settings: " + e.getMessage(), e);
log.log(Level.WARNING, "Invalid preset settings: " + e.getMessage(), e);
}
}
};
@ -425,7 +425,7 @@ public class PresetEditor extends JDialog {
setVisible(false);
}
} catch (Exception e) {
UILogger.log(Level.WARNING, "Invalid preset settings: " + e.getMessage(), e);
log.log(Level.WARNING, "Invalid preset settings: " + e.getMessage(), e);
}
}
};

View File

@ -2,8 +2,8 @@ package net.filebot.ui.rename;
import static java.util.Collections.*;
import static javax.swing.JOptionPane.*;
import static net.filebot.Logging.*;
import static net.filebot.Settings.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.ExceptionUtilities.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -75,7 +75,7 @@ class RenameAction extends AbstractAction {
Window window = getWindow(evt.getSource());
try {
if (model.files().isEmpty() || model.values().isEmpty()) {
UILogger.info("Nothing to rename. Please add some files and fetch naming data first.");
log.info("Nothing to rename. Please add some files and fetch naming data first.");
return;
}
@ -137,7 +137,7 @@ class RenameAction extends AbstractAction {
} catch (ExecutionException e) {
// ignore, handled in rename worker
} catch (Throwable e) {
UILogger.log(Level.WARNING, e.getMessage(), e);
log.log(Level.WARNING, e.getMessage(), e);
}
window.setCursor(Cursor.getDefaultCursor());
@ -341,7 +341,7 @@ class RenameAction extends AbstractAction {
this.get(); // grab exception if any
} catch (Exception e) {
if (!isCancelled()) {
UILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), e);
log.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), e);
} else {
Logger.getLogger(RenameAction.class.getName()).log(Level.SEVERE, e.getMessage(), e);
}
@ -361,7 +361,7 @@ class RenameAction extends AbstractAction {
}
if (renameLog.size() > 0) {
UILogger.info(String.format("%d files renamed.", renameLog.size()));
log.info(String.format("%d files renamed.", renameLog.size()));
HistorySpooler.getInstance().append(renameLog.entrySet());
}
}

View File

@ -4,8 +4,8 @@ import static java.awt.event.KeyEvent.*;
import static javax.swing.JOptionPane.*;
import static javax.swing.KeyStroke.*;
import static javax.swing.SwingUtilities.*;
import static net.filebot.Logging.*;
import static net.filebot.Settings.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.ExceptionUtilities.*;
import static net.filebot.util.ui.LoadingOverlayPane.*;
import static net.filebot.util.ui.SwingUI.*;
@ -651,7 +651,7 @@ public class RenamePanel extends JComponent {
// show and block
dialog.setVisible(true);
} catch (Exception e) {
UILogger.log(Level.WARNING, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), e);
log.log(Level.WARNING, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), e);
}
}
};
@ -754,7 +754,7 @@ public class RenamePanel extends JComponent {
super.actionPerformed(evt);
} catch (Exception e) {
UILogger.info(e.getMessage());
log.info(e.getMessage());
} finally {
window.setCursor(Cursor.getDefaultCursor());
}
@ -892,7 +892,7 @@ public class RenamePanel extends JComponent {
if (findCause(e, CancellationException.class) != null) {
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, getRootCause(e).toString());
} else {
UILogger.log(Level.WARNING, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), e);
log.log(Level.WARNING, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), e);
}
} finally {
// auto-match finished

View File

@ -2,10 +2,10 @@ package net.filebot.ui.sfv;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static net.filebot.Logging.*;
import static net.filebot.MediaTypes.*;
import static net.filebot.Settings.*;
import static net.filebot.hash.VerificationUtilities.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -65,7 +65,7 @@ class ChecksumTableTransferablePolicy extends BackgroundFileTransferablePolicy<C
@Override
protected void process(Exception e) {
UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
log.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
}
private final ThreadLocal<ExecutorService> executor = new ThreadLocal<ExecutorService>();

View File

@ -1,10 +1,10 @@
package net.filebot.ui.subtitle;
import static java.nio.charset.StandardCharsets.*;
import static net.filebot.Logging.*;
import static net.filebot.MediaTypes.*;
import static net.filebot.UserFiles.*;
import static net.filebot.subtitle.SubtitleUtilities.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -234,7 +234,7 @@ class SubtitleDownloadComponent extends JComponent {
} catch (CancellationException e) {
// ignore cancellation
} catch (Exception e) {
UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
log.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
// reset download
subtitle.reset();
@ -261,7 +261,7 @@ class SubtitleDownloadComponent extends JComponent {
}
}
} catch (Exception e) {
UILogger.log(Level.WARNING, e.getMessage(), e);
log.log(Level.WARNING, e.getMessage(), e);
}
}
@ -284,7 +284,7 @@ class SubtitleDownloadComponent extends JComponent {
}
}
} catch (Exception e) {
UILogger.log(Level.WARNING, e.getMessage(), e);
log.log(Level.WARNING, e.getMessage(), e);
}
}
@ -326,7 +326,7 @@ class SubtitleDownloadComponent extends JComponent {
}
}
} catch (Exception e) {
UILogger.log(Level.WARNING, e.getMessage(), e);
log.log(Level.WARNING, e.getMessage(), e);
}
}

View File

@ -1,9 +1,9 @@
package net.filebot.ui.subtitle;
import static net.filebot.Logging.*;
import static net.filebot.MediaTypes.*;
import static net.filebot.Settings.*;
import static net.filebot.UserFiles.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.ui.transfer.FileTransferable.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -128,7 +128,7 @@ abstract class SubtitleDropTarget extends JButton {
SwingUtilities.invokeLater(() -> handleDrop(files));
}
} catch (Exception e) {
UILogger.log(Level.WARNING, e.getMessage(), e);
log.log(Level.WARNING, e.getMessage(), e);
}
dtde.dropComplete(accept);
@ -167,12 +167,12 @@ abstract class SubtitleDropTarget extends JButton {
@Override
protected boolean handleDrop(List<File> input) {
if (getQueryLanguage() == null) {
UILogger.info("Please select your preferred subtitle language.");
log.info("Please select your preferred subtitle language.");
return false;
}
if (getSubtitleService().isAnonymous() && !Settings.isAppStore()) {
UILogger.info(String.format("%s: Please enter your login details.", getSubtitleService().getName()));
log.info(String.format("%s: Please enter your login details.", getSubtitleService().getName()));
return false;
}
@ -242,7 +242,7 @@ abstract class SubtitleDropTarget extends JButton {
@Override
protected boolean handleDrop(List<File> input) {
if (getSubtitleService().isAnonymous()) {
UILogger.info(String.format("%s: You must be logged in to upload subtitles.", getSubtitleService().getName()));
log.info(String.format("%s: You must be logged in to upload subtitles.", getSubtitleService().getName()));
return false;
}

View File

@ -1,8 +1,8 @@
package net.filebot.ui.subtitle;
import static net.filebot.Logging.*;
import static net.filebot.Settings.*;
import static net.filebot.ui.LanguageComboBoxModel.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -185,7 +185,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
SubtitleProvider provider = searchTextField.getSelectButton().getSelectedValue();
if (provider instanceof OpenSubtitlesClient && ((OpenSubtitlesClient) provider).isAnonymous() && !Settings.isAppStore()) {
UILogger.info(String.format("%s: Please enter your login details first.", ((OpenSubtitlesClient) provider).getName()));
log.info(String.format("%s: Please enter your login details first.", ((OpenSubtitlesClient) provider).getName()));
// automatically open login dialog
SwingUtilities.invokeLater(() -> setUserAction.actionPerformed(new ActionEvent(searchTextField, 0, "login")));
@ -372,7 +372,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
try {
// check download quota for the current user
Map<?, ?> limits = (Map<?, ?>) osdb.getServerInfo().get("download_limits");
UILogger.log(Level.INFO, String.format("Your daily download quota is at %s of %s.", limits.get("client_24h_download_count"), limits.get("client_24h_download_limit")));
log.log(Level.INFO, String.format("Your daily download quota is at %s of %s.", limits.get("client_24h_download_count"), limits.get("client_24h_download_limit")));
// logout from test session
osdb.logout();
@ -384,7 +384,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
WebServices.setLogin(WebServices.LOGIN_OPENSUBTITLES, null, null); // delete login details
}
} catch (Exception e) {
UILogger.log(Level.WARNING, "OpenSubtitles: " + e.getMessage());
log.log(Level.WARNING, "OpenSubtitles: " + e.getMessage());
approved = false;
}

View File

@ -1,7 +1,7 @@
package net.filebot.ui.subtitle.upload;
import static net.filebot.Logging.*;
import static net.filebot.media.MediaDetection.*;
import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.util.ui.SwingUI.*;
import java.awt.Component;
@ -65,7 +65,7 @@ class MovieEditor implements TableCellEditor {
return;
}
if (options.isEmpty()) {
UILogger.warning(String.format("%s: No results", database.getName()));
log.warning(String.format("%s: No results", database.getName()));
return;
}

View File

@ -1,7 +1,7 @@
package net.filebot.ui.transfer;
import static net.filebot.Logging.*;
import static net.filebot.UserFiles.*;
import static net.filebot.ui.NotificationLogging.*;
import java.awt.event.ActionEvent;
import java.io.File;
@ -58,7 +58,7 @@ public class LoadAction extends AbstractAction {
transferablePolicy.handleTransferable(transferable, getTransferAction(evt));
}
} catch (Exception e) {
UILogger.log(Level.WARNING, e.toString(), e);
log.log(Level.WARNING, e.toString(), e);
}
}