Skip to content

Add some verbose logging #25096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { PythonExtension, ResolvedEnvironment } from '../../api/types';
import { IExtensionContext, Resource } from '../../common/types';
import { commands, Uri, workspace } from 'vscode';
import { getWorkspaceStateValue, updateWorkspaceStateValue } from '../../common/persistentState';
import { traceError } from '../../logging';
import { traceError, traceVerbose } from '../../logging';
import { IExtensionActivationService } from '../../activation/types';
import { StopWatch } from '../../common/utils/stopWatch';
import { isParentPath } from '../../common/platform/fs-paths';
Expand Down Expand Up @@ -111,6 +111,9 @@ export class RecommendedEnvironmentService implements IRecommendedEnvironmentSer
const existingJson: Record<string, string> = JSON.parse(workspaceState);
const selectedEnvPath = existingJson[workspaceUri];
if (selectedEnvPath) {
traceVerbose(
`Found workspace specific environment (from memento) ${selectedEnvPath} for resource ${resource?.toString()}`,
);
return { environmentPath: selectedEnvPath, reason: 'workspaceUserSelected' };
}
} catch (ex) {
Expand All @@ -124,20 +127,34 @@ export class RecommendedEnvironmentService implements IRecommendedEnvironmentSer
// but before this version of the extension, we did not store it in the workspace state.
const workspaceEnv = await getWorkspaceSpecificVirtualEnvironment(this.api, resource);
if (workspaceEnv) {
traceVerbose(
`Found workspace specific environment (from api) ${
workspaceEnv.path
} for resource ${resource?.toString()}`,
);
return { environmentPath: workspaceEnv.path, reason: 'workspaceUserSelected' };
}
}

const globalSelectedEnvPath = this.extensionContext.globalState.get<string | undefined>(MEMENTO_KEY);
if (globalSelectedEnvPath) {
traceVerbose(
`Found global environment (from memento) ${globalSelectedEnvPath} for resource ${resource?.toString()}`,
);
return { environmentPath: globalSelectedEnvPath, reason: 'globalUserSelected' };
}
return this.api && workspace.isTrusted
? {
environmentPath: this.api.getActiveEnvironmentPath(resource).path,
reason: 'defaultRecommended',
}
: undefined;
if (this.api && workspace.isTrusted) {
const environmentPath = this.api.getActiveEnvironmentPath(resource).path;
traceVerbose(
`Found default environment (from activeEnv Path) ${environmentPath} for resource ${resource?.toString()}`,
);
return {
environmentPath,
reason: 'defaultRecommended',
};
}

return undefined;
}
}

Expand Down
Loading