mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 09:55:29 +02:00
Terminal: Enable terminal logging only if any terminal tracing option is
enabled and the bundle state location can be determined
This commit is contained in:
parent
54b71c9c08
commit
40af8fd24c
3 changed files with 22 additions and 11 deletions
|
@ -1,2 +1,3 @@
|
|||
org.eclipse.tm.terminal/debug/log = false
|
||||
org.eclipse.tm.terminal/debug/log/char = false
|
||||
org.eclipse.tm.terminal/debug/log/VT100Backend = false
|
||||
|
|
|
@ -152,7 +152,7 @@ public class VT100Emulator implements ControlListener {
|
|||
ansiParameters[i] = new StringBuffer();
|
||||
}
|
||||
setInputStreamReader(reader);
|
||||
if(TerminalPlugin.isOptionEnabled("org.eclipse.tm.terminal/debug/log/VT100Backend")) //$NON-NLS-1$
|
||||
if(TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND)) //$NON-NLS-1$
|
||||
text=new VT100BackendTraceDecorator(new VT100EmulatorBackend(data),System.out);
|
||||
else
|
||||
text=new VT100EmulatorBackend(data);
|
||||
|
|
|
@ -42,20 +42,30 @@ import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
|
|||
* </p>
|
||||
*/
|
||||
public final class Logger {
|
||||
public static final String TRACE_DEBUG_LOG_CHAR = "org.eclipse.tm.terminal/debug/log/char"; //$NON-NLS-1$
|
||||
public static final String TRACE_DEBUG_LOG = "org.eclipse.tm.terminal/debug/log"; //$NON-NLS-1$
|
||||
public static final String TRACE_DEBUG_LOG_CHAR = "org.eclipse.tm.terminal/debug/log/char"; //$NON-NLS-1$
|
||||
public static final String TRACE_DEBUG_LOG_VT100BACKEND = "org.eclipse.tm.terminal/debug/log/VT100Backend"; //$NON-NLS-1$
|
||||
|
||||
private static PrintStream logStream;
|
||||
|
||||
static {
|
||||
IPath logFile = Platform.getStateLocation(TerminalPlugin.getDefault().getBundle());
|
||||
if (logFile != null && logFile.toFile().isDirectory()) {
|
||||
logFile = logFile.append("tmterminal.log"); //$NON-NLS-1$
|
||||
try {
|
||||
logStream = new PrintStream(new FileOutputStream(logFile.toFile(), true));
|
||||
} catch (Exception ex) {
|
||||
logStream = System.err;
|
||||
logStream.println("Exception when opening log file -- logging to stderr!"); //$NON-NLS-1$
|
||||
ex.printStackTrace(logStream);
|
||||
// Any of the three known debugging options turns on the creation of the log file
|
||||
boolean createLogFile = TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG)
|
||||
|| TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_CHAR)
|
||||
|| TerminalPlugin.isOptionEnabled(TRACE_DEBUG_LOG_VT100BACKEND);
|
||||
|
||||
// Log only if tracing is enabled
|
||||
if (createLogFile && TerminalPlugin.getDefault() != null) {
|
||||
IPath logFile = Platform.getStateLocation(TerminalPlugin.getDefault().getBundle());
|
||||
if (logFile != null && logFile.toFile().isDirectory()) {
|
||||
logFile = logFile.append("tmterminal.log"); //$NON-NLS-1$
|
||||
try {
|
||||
logStream = new PrintStream(new FileOutputStream(logFile.toFile(), true));
|
||||
} catch (Exception ex) {
|
||||
logStream = System.err;
|
||||
logStream.println("Exception when opening log file -- logging to stderr!"); //$NON-NLS-1$
|
||||
ex.printStackTrace(logStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue