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:
parent
966d8da9e6
commit
deea717d27
1 changed files with 20 additions and 13 deletions
|
@ -17,6 +17,10 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.PrintStream;
|
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
|
* 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
|
* called from both class and instance methods. To use this class, write code
|
||||||
|
@ -163,10 +167,12 @@ public final class Logger {
|
||||||
* log file.
|
* log file.
|
||||||
*/
|
*/
|
||||||
public static final void logException(Exception ex) {
|
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
|
// Read my own stack to get the class name, method name, and line number
|
||||||
// of
|
// of
|
||||||
// where this method was called.
|
// where this method was called.
|
||||||
|
if(logStream!=null) {
|
||||||
StackTraceElement caller = new Throwable().getStackTrace()[1];
|
StackTraceElement caller = new Throwable().getStackTrace()[1];
|
||||||
int lineNumber = caller.getLineNumber();
|
int lineNumber = caller.getLineNumber();
|
||||||
String className = caller.getClassName();
|
String className = caller.getClassName();
|
||||||
|
@ -184,4 +190,5 @@ public final class Logger {
|
||||||
"Caught exception: " + ex); //$NON-NLS-1$
|
"Caught exception: " + ex); //$NON-NLS-1$
|
||||||
ex.printStackTrace(tmpStream);
|
ex.printStackTrace(tmpStream);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue