1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-23 16:28:51 -05:00

Unify gui/console logging

This commit is contained in:
Reinhard Pointner 2016-03-09 19:26:00 +00:00
parent f45f390d5c
commit 96b653da0a
2 changed files with 13 additions and 4 deletions

View File

@ -29,6 +29,7 @@ import java.security.Permissions;
import java.security.Policy;
import java.security.ProtectionDomain;
import java.util.Map;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -187,7 +188,11 @@ public class Main {
try {
// GUI logging settings
log.addHandler(new NotificationHandler(getApplicationName()));
log.addHandler(createSimpleFileHandler(new File(getApplicationFolder(), "error.log"), Level.WARNING)); // only log errors to file
// log errors to file
Handler error = createSimpleFileHandler(new File(getApplicationFolder(), "error.log"), Level.WARNING);
log.addHandler(error);
debug.addHandler(error);
// use native LaF an all platforms
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

View File

@ -31,7 +31,7 @@ public class NotificationHandler extends Handler {
this.timeout = timeout;
this.manager = manager;
setFormatter(new NotificationFormatter());
setFormatter(new SimpleMessageFormatter());
setLevel(Level.INFO);
}
@ -69,11 +69,15 @@ public class NotificationHandler extends Handler {
}
public static class NotificationFormatter extends Formatter {
public static class SimpleMessageFormatter extends Formatter {
@Override
public String format(LogRecord record) {
return record.getMessage();
String message = record.getMessage();
if (message == null && record.getThrown() != null) {
message = record.getThrown().toString();
}
return message;
}
}