Skip to content

Commit b141dea

Browse files
authored
debt: prepend '[pet]' to log messages for better context in NativePythonFinder (#814)
1 parent 8d5f953 commit b141dea

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/managers/common/nativePythonFinder.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class NativePythonFinderImpl implements NativePythonFinder {
202202
}
203203

204204
private start(): rpc.MessageConnection {
205-
this.outputChannel.info(`Starting Python Locator ${this.toolPath} server`);
205+
this.outputChannel.info(`[pet] Starting Python Locator ${this.toolPath} server`);
206206

207207
// jsonrpc package cannot handle messages coming through too quickly.
208208
// Lets handle the messages and close the stream only when
@@ -213,7 +213,7 @@ class NativePythonFinderImpl implements NativePythonFinder {
213213
try {
214214
const proc = ch.spawn(this.toolPath, ['server'], { env: process.env });
215215
proc.stdout.pipe(readable, { end: false });
216-
proc.stderr.on('data', (data) => this.outputChannel.error(data.toString()));
216+
proc.stderr.on('data', (data) => this.outputChannel.error(`[pet] ${data.toString()}`));
217217
writable.pipe(proc.stdin, { end: false });
218218

219219
disposables.push({
@@ -223,12 +223,12 @@ class NativePythonFinderImpl implements NativePythonFinder {
223223
proc.kill();
224224
}
225225
} catch (ex) {
226-
this.outputChannel.error('Error disposing finder', ex);
226+
this.outputChannel.error('[pet] Error disposing finder', ex);
227227
}
228228
},
229229
});
230230
} catch (ex) {
231-
this.outputChannel.error(`Error starting Python Finder ${this.toolPath} server`, ex);
231+
this.outputChannel.error(`[pet] Error starting Python Finder ${this.toolPath} server`, ex);
232232
}
233233
const connection = rpc.createMessageConnection(
234234
new rpc.StreamMessageReader(readable),
@@ -241,27 +241,28 @@ class NativePythonFinderImpl implements NativePythonFinder {
241241
writable.end();
242242
}),
243243
connection.onError((ex) => {
244-
this.outputChannel.error('Connection Error:', ex);
244+
this.outputChannel.error('[pet] Connection Error:', ex);
245245
}),
246246
connection.onNotification('log', (data: NativeLog) => {
247+
const msg = `[pet] ${data.message}`;
247248
switch (data.level) {
248249
case 'info':
249-
this.outputChannel.info(data.message);
250+
this.outputChannel.info(msg);
250251
break;
251252
case 'warning':
252-
this.outputChannel.warn(data.message);
253+
this.outputChannel.warn(msg);
253254
break;
254255
case 'error':
255-
this.outputChannel.error(data.message);
256+
this.outputChannel.error(msg);
256257
break;
257258
case 'debug':
258-
this.outputChannel.debug(data.message);
259+
this.outputChannel.debug(msg);
259260
break;
260261
default:
261-
this.outputChannel.trace(data.message);
262+
this.outputChannel.trace(msg);
262263
}
263264
}),
264-
connection.onNotification('telemetry', (data) => this.outputChannel.info(`Telemetry: `, data)),
265+
connection.onNotification('telemetry', (data) => this.outputChannel.info('[pet] Telemetry: ', data)),
265266
connection.onClose(() => {
266267
disposables.forEach((d) => d.dispose());
267268
}),
@@ -288,7 +289,9 @@ class NativePythonFinderImpl implements NativePythonFinder {
288289
executable: data.executable,
289290
})
290291
.then((environment: NativeEnvInfo) => {
291-
this.outputChannel.info(`Resolved ${environment.executable}`);
292+
this.outputChannel.info(
293+
`Resolved environment during PET refresh: ${environment.executable}`,
294+
);
292295
nativeInfo.push(environment);
293296
})
294297
.catch((ex) =>
@@ -307,7 +310,7 @@ class NativePythonFinderImpl implements NativePythonFinder {
307310
await this.connection.sendRequest<{ duration: number }>('refresh', refreshOptions);
308311
await Promise.all(unresolved);
309312
} catch (ex) {
310-
this.outputChannel.error('Error refreshing', ex);
313+
this.outputChannel.error('[pet] Error refreshing', ex);
311314
throw ex;
312315
} finally {
313316
disposables.forEach((d) => d.dispose());
@@ -333,13 +336,15 @@ class NativePythonFinderImpl implements NativePythonFinder {
333336
};
334337
// No need to send a configuration request, is there are no changes.
335338
if (JSON.stringify(options) === JSON.stringify(this.lastConfiguration || {})) {
339+
this.outputChannel.debug('[pet] configure: No changes detected, skipping configuration update.');
336340
return;
337341
}
342+
this.outputChannel.info('[pet] configure: Sending configuration update:', JSON.stringify(options));
338343
try {
339344
this.lastConfiguration = options;
340345
await this.connection.sendRequest('configure', options);
341346
} catch (ex) {
342-
this.outputChannel.error('Configuration error', ex);
347+
this.outputChannel.error('[pet] configure: Configuration error', ex);
343348
}
344349
}
345350
}

0 commit comments

Comments
 (0)