1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Streamline logging methods

This commit is contained in:
Anton Leherbauer 2008-03-13 15:22:13 +00:00
parent b1ec2cba25
commit 72d5a9c713
2 changed files with 21 additions and 11 deletions

View file

@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.CDOM;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
@ -257,11 +258,16 @@ public class CCorePlugin extends Plugin {
}
public static void log(Throwable e) {
if ( e instanceof CoreException ) {
log(((CoreException)e).getStatus());
} else {
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Error", e)); //$NON-NLS-1$
log("Error", e); //$NON-NLS-1$
}
public static void log(String message, Throwable e) {
Throwable nestedException;
if (e instanceof CModelException
&& (nestedException = ((CModelException)e).getException()) != null) {
e = nestedException;
}
log(createStatus(message, e));
}
public static IStatus createStatus(String msg) {
@ -273,7 +279,7 @@ public class CCorePlugin extends Plugin {
}
public static void log(IStatus status) {
((Plugin) getDefault()).getLog().log(status);
getDefault().getLog().log(status);
}
// ------ CPlugin

View file

@ -278,12 +278,16 @@ public class CUIPlugin extends AbstractUIPlugin {
return fgCPlugin;
}
public void log(Throwable e) {
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Error", e)); //$NON-NLS-1$
public static void log(Throwable e) {
log("Error", e); //$NON-NLS-1$
}
public void log(IStatus status) {
getLog().log(status);
public static void log(String message, Throwable e) {
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e));
}
public static void log(IStatus status) {
getDefault().getLog().log(status);
}
public void logErrorMessage(String message) {
@ -297,7 +301,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public static void errorDialog(Shell shell, String title, String message, IStatus s, boolean logError) {
if (logError)
getDefault().log(s);
log(s);
// if the 'message' resource string and the IStatus' message are the same,
// don't show both in the dialog
@ -313,7 +317,7 @@ public class CUIPlugin extends AbstractUIPlugin {
*/
public static void errorDialog(Shell shell, String title, String message, Throwable t, boolean logError) {
if (logError)
getDefault().log(t);
log(t);
IStatus status;
if (t instanceof CoreException) {