diff options
author | Tor Norbye <tnorbye@google.com> | 2013-11-26 00:59:27 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-11-26 00:59:27 +0000 |
commit | c0079867566b790408f32e9854df3a5a44dc1fb0 (patch) | |
tree | 76961191743f52eb61d02a99af0866420d9c64a4 | |
parent | 926a95a2f8698a55442e35007bee538003195cf5 (diff) | |
parent | 12a4b91b3c381a86771fc905e15f8964c52e67fb (diff) | |
download | sdk-c0079867566b790408f32e9854df3a5a44dc1fb0.zip sdk-c0079867566b790408f32e9854df3a5a44dc1fb0.tar.gz sdk-c0079867566b790408f32e9854df3a5a44dc1fb0.tar.bz2 |
Merge "Allow writing exceptions to the ADT log during rendering"
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderLogger.java | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderLogger.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderLogger.java index 7b9cb55..c0d997f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderLogger.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderLogger.java @@ -18,6 +18,7 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2; import com.android.annotations.NonNull; import com.android.annotations.Nullable; +import com.android.ide.common.rendering.RenderSecurityManager; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.eclipse.adt.AdtPlugin; @@ -123,7 +124,7 @@ public class RenderLogger extends LayoutLog { public void error(String tag, String message, Object data) { String description = describe(message); - AdtPlugin.log(IStatus.ERROR, "%1$s: %2$s", mName, description); + appendToIdeLog(null, IStatus.ERROR, description); // Workaround: older layout libraries don't provide a tag for this error if (tag == null && message != null @@ -137,7 +138,8 @@ public class RenderLogger extends LayoutLog { @Override public void error(String tag, String message, Throwable throwable, Object data) { String description = describe(message); - AdtPlugin.log(throwable, "%1$s: %2$s", mName, description); + appendToIdeLog(throwable, IStatus.ERROR, description); + if (throwable != null) { if (throwable instanceof ClassNotFoundException) { // The project callback is given a chance to resolve classes, @@ -187,7 +189,7 @@ public class RenderLogger extends LayoutLog { } if (log) { - AdtPlugin.log(IStatus.WARNING, "%1$s: %2$s", mName, description); + appendToIdeLog(null, IStatus.WARNING, description); } addWarning(tag, description); @@ -200,7 +202,8 @@ public class RenderLogger extends LayoutLog { } String description = describe(message); - AdtPlugin.log(throwable, "%1$s: %2$s", mName, description); + appendToIdeLog(throwable, IStatus.ERROR, description); + if (throwable != null) { mHaveExceptions = true; } @@ -304,4 +307,24 @@ public class RenderLogger extends LayoutLog { return false; } } + + // Append the given message to the ADT log. Bypass the sandbox if necessary + // such that we can write to the log file. + private void appendToIdeLog(Throwable throwable, int severity, String description) { + RenderSecurityManager renderSecurityManager = RenderSecurityManager.getCurrent(); + if (renderSecurityManager != null) { + renderSecurityManager.setActive(false); + } + try { + if (throwable != null) { + AdtPlugin.log(throwable, "%1$s: %2$s", mName, description); + } else { + AdtPlugin.log(severity, "%1$s: %2$s", mName, description); + } + } finally { + if (renderSecurityManager != null) { + renderSecurityManager.setActive(true); + } + } + } } |