diff --git a/plugins/org.eclipse.tm.terminal/.options b/plugins/org.eclipse.tm.terminal/.options index 5f5848c2565..78cb917d600 100644 --- a/plugins/org.eclipse.tm.terminal/.options +++ b/plugins/org.eclipse.tm.terminal/.options @@ -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 diff --git a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 76c40883f99..594bacb94f2 100644 --- a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -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); diff --git a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java index e7808a5d16e..e465587f72a 100644 --- a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java +++ b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/provisional/api/Logger.java @@ -42,20 +42,30 @@ import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; *

*/ 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); + } } } }