From 2f76465c38be8f51810204b77d7372987a64d27e Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 9 Mar 2016 16:02:36 +0000 Subject: [PATCH] Unify gui/console logging --- source/net/filebot/Logging.java | 6 +- source/net/filebot/Main.java | 46 +++++---- source/net/filebot/mac/DropToUnlock.java | 6 +- .../net/filebot/ui/AbstractSearchPanel.java | 10 +- source/net/filebot/ui/MainFrame.java | 4 +- .../net/filebot/ui/NotificationLogging.java | 94 ++++++------------- .../net/filebot/ui/analyze/ExtractTool.java | 6 +- .../analyze/FileTreeTransferablePolicy.java | 4 +- source/net/filebot/ui/list/ListPanel.java | 4 +- .../net/filebot/ui/rename/BindingDialog.java | 8 +- .../rename/FilesListTransferablePolicy.java | 4 +- .../net/filebot/ui/rename/FormatDialog.java | 4 +- .../net/filebot/ui/rename/PresetEditor.java | 6 +- .../net/filebot/ui/rename/RenameAction.java | 10 +- source/net/filebot/ui/rename/RenamePanel.java | 8 +- .../sfv/ChecksumTableTransferablePolicy.java | 4 +- .../subtitle/SubtitleDownloadComponent.java | 10 +- .../ui/subtitle/SubtitleDropTarget.java | 10 +- .../filebot/ui/subtitle/SubtitlePanel.java | 8 +- .../ui/subtitle/upload/MovieEditor.java | 4 +- .../net/filebot/ui/transfer/LoadAction.java | 4 +- 21 files changed, 116 insertions(+), 144 deletions(-) diff --git a/source/net/filebot/Logging.java b/source/net/filebot/Logging.java index 8ed7e5da..e1331248 100644 --- a/source/net/filebot/Logging.java +++ b/source/net/filebot/Logging.java @@ -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 diff --git a/source/net/filebot/Main.java b/source/net/filebot/Main.java index 86f98f05..298030ae 100644 --- a/source/net/filebot/Main.java +++ b/source/net/filebot/Main.java @@ -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 { diff --git a/source/net/filebot/mac/DropToUnlock.java b/source/net/filebot/mac/DropToUnlock.java index ee36ecc5..39106136 100644 --- a/source/net/filebot/mac/DropToUnlock.java +++ b/source/net/filebot/mac/DropToUnlock.java @@ -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 { 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)); } }); } diff --git a/source/net/filebot/ui/AbstractSearchPanel.java b/source/net/filebot/ui/AbstractSearchPanel.java index e4a150d1..43e8d68d 100644 --- a/source/net/filebot/ui/AbstractSearchPanel.java +++ b/source/net/filebot/ui/AbstractSearchPanel.java @@ -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 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 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 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); } diff --git a/source/net/filebot/ui/MainFrame.java b/source/net/filebot/ui/MainFrame.java index b511f3b9..cbe42e4d 100644 --- a/source/net/filebot/ui/MainFrame.java +++ b/source/net/filebot/ui/MainFrame.java @@ -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"); } }); diff --git a/source/net/filebot/ui/NotificationLogging.java b/source/net/filebot/ui/NotificationLogging.java index f06b23e1..32dc5466 100644 --- a/source/net/filebot/ui/NotificationLogging.java +++ b/source/net/filebot/ui/NotificationLogging.java @@ -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(); + } + } + } diff --git a/source/net/filebot/ui/analyze/ExtractTool.java b/source/net/filebot/ui/analyze/ExtractTool.java index 95593914..da7c9fde 100644 --- a/source/net/filebot/ui/analyze/ExtractTool.java +++ b/source/net/filebot/ui/analyze/ExtractTool.java @@ -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 { 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 { 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()) { diff --git a/source/net/filebot/ui/analyze/FileTreeTransferablePolicy.java b/source/net/filebot/ui/analyze/FileTreeTransferablePolicy.java index 72aa638c..49bc7c4c 100644 --- a/source/net/filebot/ui/analyze/FileTreeTransferablePolicy.java +++ b/source/net/filebot/ui/analyze/FileTreeTransferablePolicy.java @@ -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 @Override protected void process(Exception e) { - UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e); + log.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e); } } diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index 68bdc637..fafb178a 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -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)); } } }; diff --git a/source/net/filebot/ui/rename/PresetEditor.java b/source/net/filebot/ui/rename/PresetEditor.java index d7e7ec0a..a75fb1b2 100644 --- a/source/net/filebot/ui/rename/PresetEditor.java +++ b/source/net/filebot/ui/rename/PresetEditor.java @@ -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); } } }; diff --git a/source/net/filebot/ui/rename/RenameAction.java b/source/net/filebot/ui/rename/RenameAction.java index a7cc9c7c..2d1ad8b3 100644 --- a/source/net/filebot/ui/rename/RenameAction.java +++ b/source/net/filebot/ui/rename/RenameAction.java @@ -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()); } } diff --git a/source/net/filebot/ui/rename/RenamePanel.java b/source/net/filebot/ui/rename/RenamePanel.java index 005649cc..63e08e4a 100644 --- a/source/net/filebot/ui/rename/RenamePanel.java +++ b/source/net/filebot/ui/rename/RenamePanel.java @@ -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 diff --git a/source/net/filebot/ui/sfv/ChecksumTableTransferablePolicy.java b/source/net/filebot/ui/sfv/ChecksumTableTransferablePolicy.java index 1cbb13d3..a5b4035e 100644 --- a/source/net/filebot/ui/sfv/ChecksumTableTransferablePolicy.java +++ b/source/net/filebot/ui/sfv/ChecksumTableTransferablePolicy.java @@ -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 executor = new ThreadLocal(); diff --git a/source/net/filebot/ui/subtitle/SubtitleDownloadComponent.java b/source/net/filebot/ui/subtitle/SubtitleDownloadComponent.java index 217882b2..f071c783 100644 --- a/source/net/filebot/ui/subtitle/SubtitleDownloadComponent.java +++ b/source/net/filebot/ui/subtitle/SubtitleDownloadComponent.java @@ -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); } } diff --git a/source/net/filebot/ui/subtitle/SubtitleDropTarget.java b/source/net/filebot/ui/subtitle/SubtitleDropTarget.java index aa716079..305691eb 100644 --- a/source/net/filebot/ui/subtitle/SubtitleDropTarget.java +++ b/source/net/filebot/ui/subtitle/SubtitleDropTarget.java @@ -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 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 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; } diff --git a/source/net/filebot/ui/subtitle/SubtitlePanel.java b/source/net/filebot/ui/subtitle/SubtitlePanel.java index ccc1a131..8c272eaa 100644 --- a/source/net/filebot/ui/subtitle/SubtitlePanel.java +++ b/source/net/filebot/ui/subtitle/SubtitlePanel.java @@ -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 setUserAction.actionPerformed(new ActionEvent(searchTextField, 0, "login"))); @@ -372,7 +372,7 @@ public class SubtitlePanel extends AbstractSearchPanel 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