20 package org.sleuthkit.autopsy.coreutils;
22 import java.awt.Component;
23 import java.util.logging.Filter;
24 import java.util.logging.Handler;
25 import java.util.logging.Level;
26 import java.util.logging.LogRecord;
27 import java.util.logging.SimpleFormatter;
28 import javax.swing.JOptionPane;
29 import javax.swing.SwingUtilities;
30 import org.openide.util.lookup.ServiceProvider;
31 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);
60 this.setFormatter(
new SimpleFormatter());
66 if (isLoggable(record)) {
68 if (record.getMessage() != null) {
71 final int levelValue = record.getLevel().intValue();
73 final Component parentComponent = null;
74 final String message = formatExplanation(record);
75 final String title = getTitleForLevelValue(levelValue);
76 final int messageType = getMessageTypeForLevelValue(levelValue);
81 SwingUtilities.invokeLater(
new Runnable() {
85 JOptionPane.showMessageDialog(
93 logger.log(Level.SEVERE,
"Unexpected error: " + title +
", " + message );
96 nbErrorManager.publish(record);
109 return record.getThrown() != null;
119 final String logMessage = getFormatter().formatMessage(record);
120 String explanation = record.getThrown().getMessage();
121 String causeMessage = (explanation != null) ?
"\nCaused by: " + explanation :
"";
123 return logMessage + causeMessage;
141 if (levelValue >= SEVERE_VALUE) {
142 return JOptionPane.ERROR_MESSAGE;
143 }
else if (levelValue >= WARNING_VALUE) {
144 return JOptionPane.WARNING_MESSAGE;
146 return JOptionPane.INFORMATION_MESSAGE;
151 if (levelValue >= SEVERE_VALUE) {
153 }
else if (levelValue >= WARNING_VALUE) {
166 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 int getMessageTypeForLevelValue(int levelValue)
static Logger getLogger(String name)