1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Logger logs errors to eclipse error log

This commit is contained in:
Michael Scharf 2007-05-26 02:06:42 +00:00
parent 966d8da9e6
commit deea717d27

View file

@ -17,6 +17,10 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintStream;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
/**
* A simple logger class. Every method in this class is static, so they can be
* called from both class and instance methods. To use this class, write code
@ -163,10 +167,12 @@ public final class Logger {
* log file.
*/
public static final void logException(Exception ex) {
// log in eclipse error log
TerminalPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex));
// Read my own stack to get the class name, method name, and line number
// of
// where this method was called.
if(logStream!=null) {
StackTraceElement caller = new Throwable().getStackTrace()[1];
int lineNumber = caller.getLineNumber();
String className = caller.getClassName();
@ -184,4 +190,5 @@ public final class Logger {
"Caught exception: " + ex); //$NON-NLS-1$
ex.printStackTrace(tmpStream);
}
}
}