19 package org.sleuthkit.autopsy.exceptions;
21 import java.util.logging.Filter;
22 import java.util.logging.Handler;
23 import java.util.logging.Level;
24 import java.util.logging.LogRecord;
25 import java.util.logging.SimpleFormatter;
26 import javax.swing.JOptionPane;
27 import org.openide.util.lookup.ServiceProvider;
28 import org.netbeans.core.NbErrorManager;
36 @ServiceProvider(service = Handler.class, supersedes =
"org.netbeans.core.NbErrorManager")
39 static final int INFO_VALUE = Level.INFO.intValue();
40 static final int WARNING_VALUE = Level.WARNING.intValue();
41 static final int SEVERE_VALUE = Level.SEVERE.intValue();
42 static final Handler nbErrorManager =
new NbErrorManager();
49 this.setLevel(Level.SEVERE);
59 this.setFormatter(
new SimpleFormatter());
65 if (isLoggable(record)) {
66 final String title = getTitleForLevelValue(record.getLevel().intValue());
67 final String message = formatExplanation(record);
69 if (record.getMessage() != null) {
72 logger.log(Level.SEVERE,
"Unexpected error: " + title +
", " + message);
75 nbErrorManager.publish(record);
88 return record.getThrown() != null;
101 final String logMessage = getFormatter().formatMessage(record);
102 String explanation = record.getThrown().getMessage();
103 String causeMessage = (explanation != null) ?
"\nCaused by: " + explanation :
"";
105 return logMessage + causeMessage;
122 if (levelValue >= SEVERE_VALUE) {
123 return JOptionPane.ERROR_MESSAGE;
124 }
else if (levelValue >= WARNING_VALUE) {
125 return JOptionPane.WARNING_MESSAGE;
127 return JOptionPane.INFORMATION_MESSAGE;
132 if (levelValue >= SEVERE_VALUE) {
134 }
else if (levelValue >= WARNING_VALUE) {
147 public void close() throws SecurityException {
static Version.Type getBuildType()
static int getMessageTypeForLevelValue(int levelValue)
String formatExplanation(LogRecord record)
void publish(LogRecord record)
boolean isLoggable(LogRecord record)
AutopsyExceptionHandler()
static void error(String title, String message)
synchronized static Logger getLogger(String name)
static String getTitleForLevelValue(int levelValue)