diff options
author | Jonah Graham | 2021-04-22 19:58:14 +0000 |
---|---|---|
committer | Jonah Graham | 2021-04-24 01:24:45 +0000 |
commit | 4ef3cb7f303659fe4c1311cff7b419d7f0b91198 (patch) | |
tree | 3c637ace311bebe306d23df7b679d935cc463daa | |
parent | b7d017572d007bd1bc7e8564b6248229901b41ca (diff) | |
download | org.eclipse.cdt-4ef3cb7f303659fe4c1311cff7b419d7f0b91198.tar.gz org.eclipse.cdt-4ef3cb7f303659fe4c1311cff7b419d7f0b91198.tar.xz org.eclipse.cdt-4ef3cb7f303659fe4c1311cff7b419d7f0b91198.zip |
Bug 573109: Add new logging options for terminal
Change-Id: I0c35b7ce0c4350081eac6ace974dbcee3e0f103d
-rw-r--r-- | terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java index 8d109eadf76..e993ff8b7b8 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java +++ b/terminal/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java @@ -164,6 +164,8 @@ public final class Logger { * Logs the specified message. Do not append a newline to parameter * <i>message</i>. This method does that for you. * + * Does not write to the message to the Eclipse log + * * @param message A String containing the message to log. */ public static final void log(String message) { @@ -174,29 +176,43 @@ public final class Logger { } /** - * Writes a stack trace for an exception to both Standard Error and to the - * log file. + * Writes an error message to the Terminal log and the Eclipse log + * @since 5.2 + */ + public static final void logError(String message) { + logStatus(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, message, null)); + } + + /** + * Writes an exception to the Terminal log and the Eclipse log */ public static final void logException(Exception ex) { + logStatus(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex)); + } + + /** + * Writes a Status to the Terminal log and the Eclipse log + * @since 5.2 + */ + public static final void logStatus(IStatus status) { // log in eclipse error log if (TerminalPlugin.getDefault() != null) { - TerminalPlugin.getDefault().getLog() - .log(new Status(IStatus.ERROR, TerminalPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), ex)); + TerminalPlugin.getDefault().getLog().log(status); } else { - ex.printStackTrace(); + System.err.println(status); + if (status.getException() != null) { + status.getException().printStackTrace(); + } } // Additional Tracing for debug purposes: // Read my own stack to get the class name, method name, and line number // of where this method was called if (logStream != null) { - PrintStream tmpStream = System.err; - if (logStream != null) { - tmpStream = logStream; + logStream.println(getCallSiteDescription() + ": " + //$NON-NLS-1$ + status); + if (status.getException() != null) { + status.getException().printStackTrace(logStream); } - - tmpStream.println(getCallSiteDescription() + ": " + //$NON-NLS-1$ - "Caught exception: " + ex); //$NON-NLS-1$ - ex.printStackTrace(tmpStream); } } |