Skip to content

Commit 05d01e8

Browse files
committed
Fix how we pass the log directory to Editor Services
Requires the related changes to Editor Services, and now our log files make sense, hooray!
1 parent a057251 commit 05d01e8

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

Diff for: src/features/DebugSession.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ export const DebugConfigurations: Record<DebugConfig, DebugConfiguration> = {
122122

123123
export class DebugSessionFeature extends LanguageClientConsumer
124124
implements DebugConfigurationProvider, DebugAdapterDescriptorFactory {
125-
126-
private sessionCount = 1;
127125
private tempDebugProcess: PowerShellProcess | undefined;
128126
private tempSessionDetails: IEditorServicesSessionDetails | undefined;
129127
private commands: Disposable[] = [];
@@ -392,8 +390,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
392390
this.tempDebugProcess = await this.sessionManager.createDebugSessionProcess(settings);
393391
// TODO: Maybe set a timeout on the cancellation token?
394392
const cancellationTokenSource = new CancellationTokenSource();
395-
this.tempSessionDetails = await this.tempDebugProcess.start(
396-
`DebugSession-${this.sessionCount++}`, cancellationTokenSource.token);
393+
this.tempSessionDetails = await this.tempDebugProcess.start(cancellationTokenSource.token);
397394

398395
// NOTE: Dotnet attach debugging is only currently supported if a temporary debug terminal is used, otherwise we get lots of lock conflicts from loading the assemblies.
399396
if (session.configuration.attachDotnetDebugger) {

Diff for: src/logging.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export enum LogLevel {
1919
* This will allow for easy mocking of the logger during unit tests.
2020
*/
2121
export interface ILogger {
22-
getLogFilePath(baseName: string): vscode.Uri;
22+
logDirectoryPath: vscode.Uri;
2323
updateLogLevel(logLevelName: string): void;
2424
write(message: string, ...additionalMessages: string[]): void;
2525
writeAndShowInformation(message: string, ...additionalMessages: string[]): Promise<void>;
@@ -35,12 +35,11 @@ export interface ILogger {
3535
}
3636

3737
export class Logger implements ILogger {
38-
public logDirectoryPath: vscode.Uri;
39-
38+
public logDirectoryPath: vscode.Uri; // The folder for all the logs
4039
private logLevel: LogLevel;
4140
private commands: vscode.Disposable[];
4241
private logChannel: vscode.OutputChannel;
43-
private logFilePath: vscode.Uri;
42+
private logFilePath: vscode.Uri; // The client's logs
4443
private logDirectoryCreated = false;
4544
private writingLog = false;
4645

@@ -53,7 +52,7 @@ export class Logger implements ILogger {
5352
globalStorageUri.with({ scheme: "file" }),
5453
"logs",
5554
`${Math.floor(Date.now() / 1000)}-${vscode.env.sessionId}`);
56-
this.logFilePath = this.getLogFilePath("vscode-powershell");
55+
this.logFilePath = vscode.Uri.joinPath(this.logDirectoryPath, "vscode-powershell.log");
5756

5857
// Early logging of the log paths for debugging.
5958
if (LogLevel.Diagnostic >= this.logLevel) {
@@ -79,10 +78,6 @@ export class Logger implements ILogger {
7978
}
8079
}
8180

82-
public getLogFilePath(baseName: string): vscode.Uri {
83-
return vscode.Uri.joinPath(this.logDirectoryPath, `${baseName}.log`);
84-
}
85-
8681
private writeAtLevel(logLevel: LogLevel, message: string, ...additionalMessages: string[]): void {
8782
if (logLevel >= this.logLevel) {
8883
void this.writeLine(message, logLevel);

Diff for: src/process.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ export class PowerShellProcess {
3535
this.onExited = this.onExitedEmitter.event;
3636
}
3737

38-
public async start(logFileName: string, cancellationToken: vscode.CancellationToken): Promise<IEditorServicesSessionDetails | undefined> {
39-
const editorServicesLogPath = this.logger.getLogFilePath(logFileName);
40-
38+
public async start(cancellationToken: vscode.CancellationToken): Promise<IEditorServicesSessionDetails | undefined> {
4139
const psesModulePath =
4240
path.resolve(
4341
__dirname,
@@ -50,7 +48,7 @@ export class PowerShellProcess {
5048
: "";
5149

5250
this.startPsesArgs +=
53-
`-LogPath '${utils.escapeSingleQuotes(editorServicesLogPath.fsPath)}' ` +
51+
`-LogPath '${utils.escapeSingleQuotes(this.logger.logDirectoryPath.fsPath)}' ` +
5452
`-SessionDetailsPath '${utils.escapeSingleQuotes(this.sessionFilePath.fsPath)}' ` +
5553
`-FeatureFlags @(${featureFlags}) `;
5654

Diff for: src/session.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ export class SessionManager implements Middleware {
540540
}
541541
});
542542

543-
this.sessionDetails = await languageServerProcess.start("EditorServices", cancellationToken);
543+
this.sessionDetails = await languageServerProcess.start(cancellationToken);
544544

545545
return languageServerProcess;
546546
}

Diff for: test/utils.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ const packageJSON: any = require(path.resolve(rootPath, "package.json"));
1515
export const extensionId = `${packageJSON.publisher}.${packageJSON.name}`;
1616

1717
export class TestLogger implements ILogger {
18-
getLogFilePath(_baseName: string): vscode.Uri {
19-
return vscode.Uri.file("");
20-
}
18+
logDirectoryPath: vscode.Uri = vscode.Uri.file("");
2119
updateLogLevel(_logLevelName: string): void {
2220
return;
2321
}

0 commit comments

Comments
 (0)