19 package org.sleuthkit.autopsy.coreutils;
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;
33 @ServiceProvider(service = Handler.class, supersedes =
"org.netbeans.core.NbErrorManager")
36 static final int INFO_VALUE = Level.INFO.intValue();
37 static final int WARNING_VALUE = Level.WARNING.intValue();
38 static final int SEVERE_VALUE = Level.SEVERE.intValue();
39 static final Handler nbErrorManager =
new NbErrorManager();
46 this.setLevel(Level.SEVERE);
56 this.setFormatter(
new SimpleFormatter());
62 if (isLoggable(record)) {
63 final String title = getTitleForLevelValue(record.getLevel().intValue());
64 final String message = formatExplanation(record);
66 if (record.getMessage() != null) {
69 logger.log(Level.SEVERE,
"Unexpected error: " + title +
", " + message);
72 nbErrorManager.publish(record);
85 return record.getThrown() != null;
98 final String logMessage = getFormatter().formatMessage(record);
99 String explanation = record.getThrown().getMessage();
100 String causeMessage = (explanation != null) ?
"\nCaused by: " + explanation :
"";
102 return logMessage + causeMessage;
119 if (levelValue >= SEVERE_VALUE) {
120 return JOptionPane.ERROR_MESSAGE;
121 }
else if (levelValue >= WARNING_VALUE) {
122 return JOptionPane.WARNING_MESSAGE;
124 return JOptionPane.INFORMATION_MESSAGE;
129 if (levelValue >= SEVERE_VALUE) {
131 }
else if (levelValue >= WARNING_VALUE) {
144 public void close() throws SecurityException {
static Version.Type getBuildType()
String formatExplanation(LogRecord record)
void publish(LogRecord record)
static String getTitleForLevelValue(int levelValue)
boolean isLoggable(LogRecord record)
AutopsyExceptionHandler()
static void error(String title, String message)
synchronized static Logger getLogger(String name)
static int getMessageTypeForLevelValue(int levelValue)