Skip to content

Commit a76e7ef

Browse files
eleanorjboydTyriar
andauthored
remove console. in production code (#24629)
closes #9721 --------- Co-authored-by: Daniel Imms <[email protected]>
1 parent de13d42 commit a76e7ef

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

src/client/browser/extension.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ async function runPylance(
139139

140140
await client.start();
141141
} catch (e) {
142-
console.log(e);
142+
console.log(e); // necessary to use console.log for browser
143143
}
144144
}
145145

@@ -200,7 +200,7 @@ function sendTelemetryEventBrowser(
200200
break;
201201
}
202202
} catch (exception) {
203-
console.error(`Failed to serialize ${prop} for ${eventName}`, exception);
203+
console.error(`Failed to serialize ${prop} for ${eventName}`, exception); // necessary to use console.log for browser
204204
}
205205
});
206206
}

src/client/common/process/worker/workerRawProcessApis.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
StdErrError,
1818
ExecutionResult,
1919
} from './types';
20+
import { traceWarn } from '../../../logging';
2021

2122
const PS_ERROR_SCREEN_BOGUS = /your [0-9]+x[0-9]+ screen size is bogus\. expect trouble/;
2223

@@ -208,6 +209,6 @@ function killPid(pid: number): void {
208209
process.kill(pid);
209210
}
210211
} catch {
211-
console.warn('Unable to kill process with pid', pid);
212+
traceWarn('Unable to kill process with pid', pid);
212213
}
213214
}

src/client/common/utils/resourceLifecycle.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
// eslint-disable-next-line max-classes-per-file
5+
import { traceWarn } from '../../logging';
56
import { IDisposable } from '../types';
67
import { Iterable } from './iterable';
78

@@ -32,7 +33,7 @@ export function dispose<T extends IDisposable>(arg: T | Iterable<T> | undefined)
3233
try {
3334
d.dispose();
3435
} catch (e) {
35-
console.warn(`dispose() failed for ${d}`, e);
36+
traceWarn(`dispose() failed for ${d}`, e);
3637
}
3738
}
3839
}
@@ -149,7 +150,7 @@ export class DisposableStore implements IDisposable {
149150

150151
if (this._isDisposed) {
151152
if (!DisposableStore.DISABLE_DISPOSED_WARNING) {
152-
console.warn(
153+
traceWarn(
153154
new Error(
154155
'Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!',
155156
).stack,

src/client/deprecatedProposedApi.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from './deprecatedProposedApiTypes';
1414
import { IInterpreterService } from './interpreter/contracts';
1515
import { IServiceContainer } from './ioc/types';
16-
import { traceVerbose } from './logging';
16+
import { traceVerbose, traceWarn } from './logging';
1717
import { PythonEnvInfo } from './pythonEnvironments/base/info';
1818
import { getEnvPath } from './pythonEnvironments/base/info/env';
1919
import { GetRefreshEnvironmentsOptions, IDiscoveryAPI } from './pythonEnvironments/base/locator';
@@ -74,7 +74,7 @@ export function buildDeprecatedProposedApi(
7474
});
7575
traceVerbose(`Extension ${info.extensionId} accessed ${apiName}`);
7676
if (warnLog && !warningLogged.has(info.extensionId)) {
77-
console.warn(
77+
traceWarn(
7878
`${info.extensionId} extension is using deprecated python APIs which will be removed soon.`,
7979
);
8080
warningLogged.add(info.extensionId);

src/client/repl/pythonServer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PythonServerImpl implements PythonServer, Disposable {
3838
private initialize(): void {
3939
this.disposables.push(
4040
this.connection.onNotification('log', (message: string) => {
41-
console.log('Log:', message);
41+
traceLog('Log:', message);
4242
}),
4343
);
4444
this.connection.listen();

src/client/telemetry/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export function sendTelemetryEvent<P extends IEventNamePropertyMapping, E extend
136136
break;
137137
}
138138
} catch (exception) {
139-
console.error(`Failed to serialize ${prop} for ${String(eventName)}`, exception);
139+
console.error(`Failed to serialize ${prop} for ${String(eventName)}`, exception); // use console due to circular dependencies with trace calls
140140
}
141141
});
142142
}
@@ -160,7 +160,7 @@ export function sendTelemetryEvent<P extends IEventNamePropertyMapping, E extend
160160
`Telemetry Event : ${eventNameSent} Measures: ${JSON.stringify(measures)} Props: ${JSON.stringify(
161161
customProperties,
162162
)} `,
163-
);
163+
); // use console due to circular dependencies with trace calls
164164
}
165165
}
166166

src/client/testing/testController/common/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function startRunResultNamedPipe(
8989
if (cancellationToken) {
9090
disposables.push(
9191
cancellationToken?.onCancellationRequested(() => {
92-
console.log(`Test Result named pipe ${pipeName} cancelled`);
92+
traceLog(`Test Result named pipe ${pipeName} cancelled`);
9393
disposable.dispose();
9494
}),
9595
);
@@ -345,7 +345,7 @@ export async function hasSymlinkParent(currentPath: string): Promise<boolean> {
345345
// Recurse up the directory tree
346346
return await hasSymlinkParent(parentDirectory);
347347
} catch (error) {
348-
console.error('Error checking symlinks:', error);
348+
traceError('Error checking symlinks:', error);
349349
return false;
350350
}
351351
}

src/client/testing/testController/pytest/pytestExecutionAdapter.ts

-3
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,6 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
283283
runInstance,
284284
);
285285
}
286-
// this doesn't work, it instead directs us to the noop one which is defined first
287-
// potentially this is due to the server already being close, if this is the case?
288-
console.log('right before serverDispose');
289286
}
290287

291288
// deferredTillEOT is resolved when all data sent on stdout and stderr is received, close event is only called when this occurs

0 commit comments

Comments
 (0)