1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-02 08:25:02 -04:00

only log errors to file

This commit is contained in:
Reinhard Pointner 2016-03-09 16:18:20 +00:00
parent 2f76465c38
commit f45f390d5c
3 changed files with 17 additions and 9 deletions

View File

@ -1,5 +1,8 @@
package net.filebot;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.function.Supplier;
import java.util.logging.Formatter;
@ -7,6 +10,8 @@ import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.logging.StreamHandler;
import java.util.regex.Pattern;
import net.filebot.util.SystemProperty;
@ -29,6 +34,12 @@ public final class Logging {
return log;
}
public static StreamHandler createSimpleFileHandler(File file, Level level) throws IOException {
StreamHandler handler = new StreamHandler(new FileOutputStream(file, true), new SimpleFormatter());
handler.setLevel(level);
return handler;
}
public static Supplier<String> format(String format, Object... args) {
return () -> String.format(format, args);
}

View File

@ -15,7 +15,6 @@ 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;
@ -32,8 +31,6 @@ import java.security.ProtectionDomain;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.StreamHandler;
import java.util.logging.XMLFormatter;
import javax.swing.JDialog;
import javax.swing.JFrame;
@ -51,7 +48,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.NotificationHandler;
import net.filebot.ui.PanelBuilder;
import net.filebot.ui.SinglePanelFrame;
import net.filebot.ui.transfer.FileTransferable;
@ -189,8 +186,8 @@ public class Main {
private static void startUserInterface(ArgumentBean args) {
try {
// GUI logging settings
log.addHandler(new NotificationLogging(getApplicationName()));
log.addHandler(new StreamHandler(new FileOutputStream(new File(getApplicationFolder(), "error.log.xml"), true), new XMLFormatter()));
log.addHandler(new NotificationHandler(getApplicationName()));
log.addHandler(createSimpleFileHandler(new File(getApplicationFolder(), "error.log"), Level.WARNING)); // only log errors to file
// use native LaF an all platforms
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

View File

@ -16,17 +16,17 @@ 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 class NotificationHandler extends Handler {
private final String title;
private final int timeout;
private final NotificationManager manager;
public NotificationLogging(String title) {
public NotificationHandler(String title) {
this(title, 2500, new NotificationManager(new QueueNotificationLayout(NORTH, SOUTH)));
}
public NotificationLogging(String title, int timeout, NotificationManager manager) {
public NotificationHandler(String title, int timeout, NotificationManager manager) {
this.title = title;
this.timeout = timeout;
this.manager = manager;