@@ -5,7 +5,7 @@ import * as path from 'path';
55import { commands , ConfigurationChangeEvent , Disposable , l10n , Uri , workspace } from 'vscode' ;
66import { PythonEnvironment , PythonEnvironmentApi } from '../api' ;
77import { SYSTEM_MANAGER_ID , VENV_MANAGER_ID } from '../common/constants' ;
8- import { traceInfo , traceVerbose , traceWarn } from '../common/logging' ;
8+ import { traceError , traceInfo , traceVerbose , traceWarn } from '../common/logging' ;
99import { showWarningMessage } from '../common/window.apis' ;
1010import { getConfiguration , onDidChangeConfiguration } from '../common/workspace.apis' ;
1111import { getUserConfiguredSetting } from '../helpers' ;
@@ -59,9 +59,7 @@ async function resolvePriorityChainCore(
5959 api : PythonEnvironmentApi ,
6060) : Promise < { result : PriorityChainResult ; errors : SettingResolutionError [ ] } > {
6161 const errors : SettingResolutionError [ ] = [ ] ;
62- const logPrefix = scope ? `[resolveEnvironmentByPriority] ${ scope . fsPath } ` : '[resolveGlobalEnvironmentByPriority]' ;
63-
64- traceVerbose ( `${ logPrefix } Starting priority chain resolution` ) ;
62+ const logPrefix = scope ? `[priorityChain] ${ scope . fsPath } ` : '[priorityChain:global]' ;
6563
6664 // PRIORITY 1: Check pythonProjects[] for this workspace path (workspace scope only)
6765 if ( scope && projectManager ) {
@@ -78,7 +76,7 @@ async function resolvePriorityChainCore(
7876 reason : `Environment manager '${ projectManagerId } ' is not registered` ,
7977 } ;
8078 errors . push ( error ) ;
81- traceWarn ( `${ logPrefix } ${ error . reason } ` ) ;
79+ traceWarn ( `${ logPrefix } pythonProjects[] manager ' ${ projectManagerId } ' not found, trying next priority ` ) ;
8280 }
8381 }
8482
@@ -96,7 +94,7 @@ async function resolvePriorityChainCore(
9694 reason : `Environment manager '${ userConfiguredManager } ' is not registered` ,
9795 } ;
9896 errors . push ( error ) ;
99- traceWarn ( `${ logPrefix } ${ error . reason } ` ) ;
97+ traceWarn ( `${ logPrefix } defaultEnvManager ' ${ userConfiguredManager } ' not found, trying next priority ` ) ;
10098 }
10199
102100 // PRIORITY 3: User-configured python.defaultInterpreterPath
@@ -113,11 +111,12 @@ async function resolvePriorityChainCore(
113111 reason : `Could not resolve interpreter path '${ userInterpreterPath } '` ,
114112 } ;
115113 errors . push ( error ) ;
116- traceWarn ( `${ logPrefix } ${ error . reason } , falling through to auto-discovery` ) ;
114+ traceWarn (
115+ `${ logPrefix } defaultInterpreterPath '${ userInterpreterPath } ' unresolvable, falling back to auto-discovery` ,
116+ ) ;
117117 }
118118
119- // PRIORITY 4: Auto-discovery
120- traceVerbose ( `${ logPrefix } Priority 4: Falling through to auto-discovery` ) ;
119+ // PRIORITY 4: Auto-discovery (no user-configured settings matched)
121120 const autoDiscoverResult = await autoDiscoverEnvironment ( scope , envManagers ) ;
122121 return { result : autoDiscoverResult , errors } ;
123122}
@@ -186,26 +185,24 @@ async function autoDiscoverEnvironment(
186185 try {
187186 const localEnv = await venvManager . get ( scope ) ;
188187 if ( localEnv ) {
189- traceVerbose ( `[autoDiscover] Priority 4: Auto-discovered local venv: ${ localEnv . displayName } ` ) ;
190188 return { manager : venvManager , environment : localEnv , source : 'autoDiscovery' } ;
191189 }
192190 } catch ( err ) {
193- traceWarn ( `[autoDiscover] Error checking venv manager: ${ err } ` ) ;
191+ traceError ( `[autoDiscover] Failed to check venv manager: ${ err } ` ) ;
194192 }
195193 }
196194 }
197195
198196 // Fall back to system manager
199197 const systemManager = envManagers . getEnvironmentManager ( SYSTEM_MANAGER_ID ) ;
200198 if ( systemManager ) {
201- traceVerbose ( '[autoDiscover] Priority 4: Using system Python (fallback)' ) ;
202199 return { manager : systemManager , source : 'autoDiscovery' } ;
203200 }
204201
205202 // Last resort: use any available manager
206203 const anyManager = envManagers . managers [ 0 ] ;
207204 if ( anyManager ) {
208- traceVerbose ( `[autoDiscover] Priority 4: No venv or system manager, using first available : ${ anyManager . id } ` ) ;
205+ traceWarn ( `[autoDiscover] No venv or system manager available , using fallback manager : ${ anyManager . id } ` ) ;
209206 return { manager : anyManager , source : 'autoDiscovery' } ;
210207 }
211208
@@ -238,7 +235,9 @@ export async function applyInitialEnvironmentSelection(
238235 api : PythonEnvironmentApi ,
239236) : Promise < void > {
240237 const folders = workspace . workspaceFolders ?? [ ] ;
241- traceVerbose ( `[applyInitialEnvironmentSelection] Starting - ${ folders . length } workspace folder(s)` ) ;
238+ traceInfo (
239+ `[interpreterSelection] Applying initial environment selection for ${ folders . length } workspace folder(s)` ,
240+ ) ;
242241
243242 const allErrors : SettingResolutionError [ ] = [ ] ;
244243
@@ -259,12 +258,11 @@ export async function applyInitialEnvironmentSelection(
259258 // Cache only — NO settings.json write (shouldPersistSettings = false)
260259 await envManagers . setEnvironment ( folder . uri , env , false ) ;
261260
262- traceVerbose (
263- `[applyInitialEnvironmentSelection] Set environment for ${ folder . uri . fsPath } : ` +
264- `manager=${ result . manager . id } , source=${ result . source } , env=${ env ?. displayName ?? 'none' } ` ,
261+ traceInfo (
262+ `[interpreterSelection] ${ folder . name } : ${ env ?. displayName ?? 'none' } (source: ${ result . source } )` ,
265263 ) ;
266264 } catch ( err ) {
267- traceWarn ( `[applyInitialEnvironmentSelection] Error setting environment for ${ folder . uri . fsPath } : ${ err } ` ) ;
265+ traceError ( `[interpreterSelection] Failed to set environment for ${ folder . uri . fsPath } : ${ err } ` ) ;
268266 }
269267 }
270268
@@ -280,12 +278,9 @@ export async function applyInitialEnvironmentSelection(
280278 // Cache only — NO settings.json write (shouldPersistSettings = false)
281279 await envManagers . setEnvironments ( 'global' , env , false ) ;
282280
283- traceVerbose (
284- `[applyInitialEnvironmentSelection] Set global environment: ` +
285- `manager=${ result . manager . id } , source=${ result . source } , env=${ env ?. displayName ?? 'none' } ` ,
286- ) ;
281+ traceInfo ( `[interpreterSelection] global: ${ env ?. displayName ?? 'none' } (source: ${ result . source } )` ) ;
287282 } catch ( err ) {
288- traceWarn ( `[applyInitialEnvironmentSelection] Error setting global environment: ${ err } ` ) ;
283+ traceError ( `[interpreterSelection] Failed to set global environment: ${ err } ` ) ;
289284 }
290285
291286 // Notify user if any settings could not be applied
@@ -409,11 +404,17 @@ async function tryResolveInterpreterPath(
409404 } ,
410405 } ,
411406 } ;
407+ traceVerbose (
408+ `[tryResolveInterpreterPath] Resolved '${ interpreterPath } ' to ${ resolved . executable } (${ resolved . version } )` ,
409+ ) ;
412410 return { manager, environment : newEnv , source : 'defaultInterpreterPath' } ;
413411 }
414412 }
413+ traceVerbose (
414+ `[tryResolveInterpreterPath] Could not resolve '${ interpreterPath } ' - no executable or manager found` ,
415+ ) ;
415416 } catch ( err ) {
416- traceWarn ( `[tryResolveInterpreterPath] Error resolving interpreter path : ${ err } ` ) ;
417+ traceVerbose ( `[tryResolveInterpreterPath] Resolution failed for ' ${ interpreterPath } ' : ${ err } ` ) ;
417418 }
418419 return undefined ;
419420}
0 commit comments