Skip to content

Commit e2eda0a

Browse files
committed
Substitute process ID for "PID" in log file names
This will help us solve the problem of logs getting clobbered when the server restarts.
1 parent c667a98 commit e2eda0a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/tsserver/server.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -644,14 +644,18 @@ namespace ts.server {
644644
const cmdLineVerbosity = getLogLevel(findArgument("--logVerbosity"));
645645
const envLogOptions = parseLoggingEnvironmentString(process.env.TSS_LOG);
646646

647-
const logFileName = cmdLineLogFileName
647+
const unsubstitutedLogFileName = cmdLineLogFileName
648648
? stripQuotes(cmdLineLogFileName)
649649
: envLogOptions.logToFile
650650
? envLogOptions.file || (__dirname + "/.log" + process.pid.toString())
651651
: undefined;
652652

653+
const substitutedLogFileName = unsubstitutedLogFileName
654+
? unsubstitutedLogFileName.replace("PID", process.pid.toString())
655+
: undefined;
656+
653657
const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel;
654-
return new Logger(logFileName!, envLogOptions.traceToConsole!, logVerbosity!); // TODO: GH#18217
658+
return new Logger(substitutedLogFileName!, envLogOptions.traceToConsole!, logVerbosity!); // TODO: GH#18217
655659
}
656660
// This places log file in the directory containing editorServices.js
657661
// TODO: check that this location is writable

0 commit comments

Comments
 (0)