Skip to content

Commit b528e1d

Browse files
Add more logging
1 parent beeeb54 commit b528e1d

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

src/extension/debugger/configuration/launch.json/launchJsonReader.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ import * as fs from 'fs-extra';
66
import { parse } from 'jsonc-parser';
77
import { DebugConfiguration, Uri, WorkspaceFolder } from 'vscode';
88
import { getConfiguration, getWorkspaceFolder } from '../../../common/vscodeapi';
9+
import { traceLog } from '../../../common/log/logging';
910

1011
export async function getConfigurationsForWorkspace(workspace: WorkspaceFolder): Promise<DebugConfiguration[]> {
12+
traceLog('Getting configurations for workspace');
1113
const filename = path.join(workspace.uri.fsPath, '.vscode', 'launch.json');
1214
if (!(await fs.pathExists(filename))) {
1315
// Check launch config in the workspace file
1416
const codeWorkspaceConfig = getConfiguration('launch', workspace);
1517
if (!codeWorkspaceConfig.configurations || !Array.isArray(codeWorkspaceConfig.configurations)) {
1618
return [];
1719
}
20+
traceLog('Using configuration in workspace');
1821
return codeWorkspaceConfig.configurations;
1922
}
2023

@@ -26,7 +29,7 @@ export async function getConfigurationsForWorkspace(workspace: WorkspaceFolder):
2629
if (!parsed.version) {
2730
throw Error('Missing field in launch.json: version');
2831
}
29-
// We do not bother ensuring each item is a DebugConfiguration...
32+
traceLog("Using configuration in launch.json");
3033
return parsed.configurations;
3134
}
3235

src/extension/debugger/configuration/resolvers/attach.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import { getOSType, OSType } from '../../../common/platform';
88
import { AttachRequestArguments, DebugOptions, PathMapping } from '../../../types';
99
import { BaseConfigurationResolver } from './base';
1010
import { getConfiguration } from '../../../common/vscodeapi';
11+
import { traceLog } from '../../../common/log/logging';
1112

1213
export class AttachConfigurationResolver extends BaseConfigurationResolver<AttachRequestArguments> {
1314
public async resolveDebugConfigurationWithSubstitutedVariables(
1415
folder: WorkspaceFolder | undefined,
1516
debugConfiguration: AttachRequestArguments,
1617
_token?: CancellationToken,
1718
): Promise<AttachRequestArguments | undefined> {
19+
traceLog('Resolving attach configuration with substituted variables');
1820
const workspaceFolder = AttachConfigurationResolver.getWorkspaceFolder(folder);
1921

2022
await this.provideAttachDefaults(workspaceFolder, debugConfiguration as AttachRequestArguments);

src/extension/debugger/configuration/resolvers/base.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { resolveVariables } from '../utils/common';
1616
import { getProgram } from './helper';
1717
import { getSettingsPythonPath, getInterpreterDetails } from '../../../common/python';
1818
import { getOSType, OSType } from '../../../common/platform';
19+
import { traceLog } from '../../../common/log/logging';
1920

2021
export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
2122
implements IDebugConfigurationResolver<T>
@@ -62,14 +63,17 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
6263
const workspaceFolders = getWorkspaceFolders();
6364

6465
if (!Array.isArray(workspaceFolders) || workspaceFolders.length === 0) {
66+
traceLog("No workspace folder found");
6567
return program ? Uri.file(path.dirname(program)) : undefined;
6668
}
6769
if (workspaceFolders.length === 1) {
70+
traceLog("Using the only workspaceFolder found: ", workspaceFolders[0].uri.fsPath);
6871
return workspaceFolders[0].uri;
6972
}
7073
if (program) {
7174
const workspaceFolder = getVSCodeWorkspaceFolder(Uri.file(program));
7275
if (workspaceFolder) {
76+
traceLog("Using workspaceFolder found for the program: ", workspaceFolder.uri.fsPath);
7377
return workspaceFolder.uri;
7478
}
7579
}

src/extension/extensionInit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ export async function registerDebugger(context: IExtensionContext): Promise<IExt
8484

8585
context.subscriptions.push(
8686
registerCommand(Commands.Debug_In_Terminal, async (file?: Uri) => {
87+
traceLog("Debugging using the editor button 'Debug in terminal'");
8788
sendTelemetryEvent(EventName.DEBUG_IN_TERMINAL_BUTTON);
8889
const interpreter = await getInterpreterDetails(file);
8990
if (!interpreter.path) {
9091
runPythonExtensionCommand(Commands.TriggerEnvironmentSelection, file).then(noop, noop);
9192
return;
9293
}
9394
const config = await getDebugConfiguration(file);
94-
traceLog("Debugging using the editor button 'Debug in terminal'");
9595
startDebugging(undefined, config);
9696
}),
9797
);

0 commit comments

Comments
 (0)