mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
Terminal: Move terminal logging into workspace state location (if exist)
This commit is contained in:
parent
ab0be06cdb
commit
08592ec36d
1 changed files with 7 additions and 16 deletions
|
@ -13,11 +13,12 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.provisional.api;
|
package org.eclipse.tm.internal.terminal.provisional.api;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
|
import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin;
|
||||||
|
|
||||||
|
@ -50,24 +51,14 @@ public final class Logger {
|
||||||
private static PrintStream logStream;
|
private static PrintStream logStream;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
String logFile = null;
|
IPath logFile = Platform.getStateLocation(TerminalPlugin.getDefault().getBundle());
|
||||||
//TODO I think this should go into the workspace metadata instead.
|
if (logFile != null && logFile.toFile().isDirectory()) {
|
||||||
File logDirWindows = new File("C:\\eclipselogs"); //$NON-NLS-1$
|
logFile = logFile.append("tmterminal.log"); //$NON-NLS-1$
|
||||||
File logDirUNIX = new File("/tmp/eclipselogs"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
if (logDirWindows.isDirectory()) {
|
|
||||||
logFile = logDirWindows + "\\tmterminal.log"; //$NON-NLS-1$
|
|
||||||
} else if (logDirUNIX.isDirectory()) {
|
|
||||||
logFile = logDirUNIX + "/tmterminal.log"; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logFile != null) {
|
|
||||||
try {
|
try {
|
||||||
logStream = new PrintStream(new FileOutputStream(logFile, true));
|
logStream = new PrintStream(new FileOutputStream(logFile.toFile(), true));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logStream = System.err;
|
logStream = System.err;
|
||||||
logStream
|
logStream.println("Exception when opening log file -- logging to stderr!"); //$NON-NLS-1$
|
||||||
.println("Exception when opening log file -- logging to stderr!"); //$NON-NLS-1$
|
|
||||||
ex.printStackTrace(logStream);
|
ex.printStackTrace(logStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue