diff --git a/src/client/browser/extension.ts b/src/client/browser/extension.ts index 35854d141cad..3d672b7f29e2 100644 --- a/src/client/browser/extension.ts +++ b/src/client/browser/extension.ts @@ -12,6 +12,7 @@ import { EventName } from '../telemetry/constants'; import { createStatusItem } from './intellisenseStatus'; import { PylanceApi } from '../activation/node/pylanceApi'; import { buildApi, IBrowserExtensionApi } from './api'; +import { traceError, traceLog } from '../logging'; interface BrowserConfig { distUrl: string; // URL to Pylance's dist folder. @@ -139,7 +140,7 @@ async function runPylance( await client.start(); } catch (e) { - console.log(e); + traceLog(e); } } @@ -200,7 +201,7 @@ function sendTelemetryEventBrowser( break; } } catch (exception) { - console.error(`Failed to serialize ${prop} for ${eventName}`, exception); + traceError(`Failed to serialize ${prop} for ${eventName}`, exception); } }); } diff --git a/src/client/common/process/worker/workerRawProcessApis.ts b/src/client/common/process/worker/workerRawProcessApis.ts index 5b04aaa40b0a..cfae9b1e6471 100644 --- a/src/client/common/process/worker/workerRawProcessApis.ts +++ b/src/client/common/process/worker/workerRawProcessApis.ts @@ -17,6 +17,7 @@ import { StdErrError, ExecutionResult, } from './types'; +import { traceWarn } from '../../../logging'; const PS_ERROR_SCREEN_BOGUS = /your [0-9]+x[0-9]+ screen size is bogus\. expect trouble/; @@ -208,6 +209,6 @@ function killPid(pid: number): void { process.kill(pid); } } catch { - console.warn('Unable to kill process with pid', pid); + traceWarn('Unable to kill process with pid', pid); } } diff --git a/src/client/common/utils/resourceLifecycle.ts b/src/client/common/utils/resourceLifecycle.ts index f41efebc12cb..b5d1a9a1c83a 100644 --- a/src/client/common/utils/resourceLifecycle.ts +++ b/src/client/common/utils/resourceLifecycle.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. // eslint-disable-next-line max-classes-per-file +import { traceWarn } from '../../logging'; import { IDisposable } from '../types'; import { Iterable } from './iterable'; @@ -32,7 +33,7 @@ export function dispose(arg: T | Iterable | undefined) try { d.dispose(); } catch (e) { - console.warn(`dispose() failed for ${d}`, e); + traceWarn(`dispose() failed for ${d}`, e); } } } @@ -149,7 +150,7 @@ export class DisposableStore implements IDisposable { if (this._isDisposed) { if (!DisposableStore.DISABLE_DISPOSED_WARNING) { - console.warn( + traceWarn( new Error( 'Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!', ).stack, diff --git a/src/client/deprecatedProposedApi.ts b/src/client/deprecatedProposedApi.ts index e63670e4bf1b..d0003c895517 100644 --- a/src/client/deprecatedProposedApi.ts +++ b/src/client/deprecatedProposedApi.ts @@ -13,7 +13,7 @@ import { } from './deprecatedProposedApiTypes'; import { IInterpreterService } from './interpreter/contracts'; import { IServiceContainer } from './ioc/types'; -import { traceVerbose } from './logging'; +import { traceVerbose, traceWarn } from './logging'; import { PythonEnvInfo } from './pythonEnvironments/base/info'; import { getEnvPath } from './pythonEnvironments/base/info/env'; import { GetRefreshEnvironmentsOptions, IDiscoveryAPI } from './pythonEnvironments/base/locator'; @@ -74,7 +74,7 @@ export function buildDeprecatedProposedApi( }); traceVerbose(`Extension ${info.extensionId} accessed ${apiName}`); if (warnLog && !warningLogged.has(info.extensionId)) { - console.warn( + traceWarn( `${info.extensionId} extension is using deprecated python APIs which will be removed soon.`, ); warningLogged.add(info.extensionId); diff --git a/src/client/repl/pythonServer.ts b/src/client/repl/pythonServer.ts index 0f500f0431bc..570433714f98 100644 --- a/src/client/repl/pythonServer.ts +++ b/src/client/repl/pythonServer.ts @@ -38,7 +38,7 @@ class PythonServerImpl implements PythonServer, Disposable { private initialize(): void { this.disposables.push( this.connection.onNotification('log', (message: string) => { - console.log('Log:', message); + traceLog('Log:', message); }), ); this.connection.listen(); diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 357f6e60768a..365a4e593f28 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -136,7 +136,7 @@ export function sendTelemetryEvent

{ - console.log(`Test Result named pipe ${pipeName} cancelled`); + traceLog(`Test Result named pipe ${pipeName} cancelled`); disposable.dispose(); }), ); @@ -345,7 +345,7 @@ export async function hasSymlinkParent(currentPath: string): Promise { // Recurse up the directory tree return await hasSymlinkParent(parentDirectory); } catch (error) { - console.error('Error checking symlinks:', error); + traceError('Error checking symlinks:', error); return false; } } diff --git a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts index 6413baf8baee..0a0d802ef32e 100644 --- a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts +++ b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts @@ -273,20 +273,17 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter { // if the child has testIds then this is a run request // if the child process exited with a non-zero exit code, then we need to send the error payload. if (code !== 0) { - traceError( - `Subprocess closed unsuccessfully with exit code ${code} and signal ${signal} for workspace ${uri.fsPath}. Creating and sending error execution payload \n`, - ); + traceError( + `Subprocess closed unsuccessfully with exit code ${code} and signal ${signal} for workspace ${uri.fsPath}. Creating and sending error execution payload \n`, + ); - if (runInstance) { - this.resultResolver?.resolveExecution( - utils.createExecutionErrorPayload(code, signal, testIds, cwd), - runInstance, - ); - } - // this doesn't work, it instead directs us to the noop one which is defined first - // potentially this is due to the server already being close, if this is the case? - console.log('right before serverDispose'); - } + if (runInstance) { + this.resultResolver?.resolveExecution( + utils.createExecutionErrorPayload(code, signal, testIds, cwd), + runInstance, + ); + } + } // deferredTillEOT is resolved when all data sent on stdout and stderr is received, close event is only called when this occurs // due to the sync reading of the output.