mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 00:38:52 -05:00
Unify gui/console logging
This commit is contained in:
parent
f45f390d5c
commit
96b653da0a
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user