* consider headless environments
This commit is contained in:
parent
baf65babcc
commit
e64d97b222
|
@ -5,6 +5,7 @@ package net.sourceforge.filebot.ui;
|
||||||
import static net.sourceforge.filebot.Settings.*;
|
import static net.sourceforge.filebot.Settings.*;
|
||||||
import static net.sourceforge.tuned.ui.notification.Direction.*;
|
import static net.sourceforge.tuned.ui.notification.Direction.*;
|
||||||
|
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.util.logging.ConsoleHandler;
|
import java.util.logging.ConsoleHandler;
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -25,7 +26,7 @@ public class NotificationLogging extends Handler {
|
||||||
|
|
||||||
public static final Logger UILogger = createNotificationLogger("net.sourceforge.filebot.ui");
|
public static final Logger UILogger = createNotificationLogger("net.sourceforge.filebot.ui");
|
||||||
|
|
||||||
|
|
||||||
private static Logger createNotificationLogger(String name) {
|
private static Logger createNotificationLogger(String name) {
|
||||||
Logger log = Logger.getLogger(name);
|
Logger log = Logger.getLogger(name);
|
||||||
|
|
||||||
|
@ -43,23 +44,26 @@ public class NotificationLogging extends Handler {
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final NotificationManager notificationManager;
|
public final NotificationManager notificationManager;
|
||||||
public final int timeout = 2500;
|
public final int timeout = 2500;
|
||||||
|
|
||||||
|
|
||||||
public NotificationLogging() {
|
public NotificationLogging() {
|
||||||
this(new NotificationManager(new QueueNotificationLayout(NORTH, SOUTH)));
|
this(new NotificationManager(new QueueNotificationLayout(NORTH, SOUTH)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NotificationLogging(NotificationManager notificationManager) {
|
public NotificationLogging(NotificationManager notificationManager) {
|
||||||
this.notificationManager = notificationManager;
|
this.notificationManager = notificationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publish(LogRecord record) {
|
public void publish(LogRecord record) {
|
||||||
|
// fail gracefully on an headless machine
|
||||||
|
if (GraphicsEnvironment.isHeadless())
|
||||||
|
return;
|
||||||
|
|
||||||
final Level level = record.getLevel();
|
final Level level = record.getLevel();
|
||||||
final String message = getMessage(record);
|
final String message = getMessage(record);
|
||||||
|
|
||||||
|
@ -78,7 +82,7 @@ public class NotificationLogging extends Handler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String getMessage(LogRecord record) {
|
protected String getMessage(LogRecord record) {
|
||||||
String message = record.getMessage();
|
String message = record.getMessage();
|
||||||
|
|
||||||
|
@ -90,18 +94,18 @@ public class NotificationLogging extends Handler {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void show(String message, Icon icon, int timeout) {
|
protected void show(String message, Icon icon, int timeout) {
|
||||||
notificationManager.show(new MessageNotification(getApplicationName(), message, icon, timeout));
|
notificationManager.show(new MessageNotification(getApplicationName(), message, icon, timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws SecurityException {
|
public void close() throws SecurityException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue