Skip to content
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

remove console. in production code #24629

Merged
merged 8 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/client/browser/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async function runPylance(

await client.start();
} catch (e) {
console.log(e);
console.log(e); // necessary to use console.log for browser
eleanorjboyd marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -200,7 +200,7 @@ function sendTelemetryEventBrowser(
break;
}
} catch (exception) {
console.error(`Failed to serialize ${prop} for ${eventName}`, exception);
console.error(`Failed to serialize ${prop} for ${eventName}`, exception); // necessary to use console.log for browser
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/client/common/process/worker/workerRawProcessApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/;

Expand Down Expand Up @@ -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);
}
}
5 changes: 3 additions & 2 deletions src/client/common/utils/resourceLifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -32,7 +33,7 @@ export function dispose<T extends IDisposable>(arg: T | Iterable<T> | undefined)
try {
d.dispose();
} catch (e) {
console.warn(`dispose() failed for ${d}`, e);
traceWarn(`dispose() failed for ${d}`, e);
}
}
}
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/client/deprecatedProposedApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/client/repl/pythonServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function sendTelemetryEvent<P extends IEventNamePropertyMapping, E extend
break;
}
} catch (exception) {
console.error(`Failed to serialize ${prop} for ${String(eventName)}`, exception);
console.error(`Failed to serialize ${prop} for ${String(eventName)}`, exception); // use console due to circular dependencies with trace calls
}
});
}
Expand All @@ -160,7 +160,7 @@ export function sendTelemetryEvent<P extends IEventNamePropertyMapping, E extend
`Telemetry Event : ${eventNameSent} Measures: ${JSON.stringify(measures)} Props: ${JSON.stringify(
customProperties,
)} `,
);
); // use console due to circular dependencies with trace calls
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/client/testing/testController/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function startRunResultNamedPipe(
if (cancellationToken) {
disposables.push(
cancellationToken?.onCancellationRequested(() => {
console.log(`Test Result named pipe ${pipeName} cancelled`);
traceLog(`Test Result named pipe ${pipeName} cancelled`);
disposable.dispose();
}),
);
Expand Down Expand Up @@ -345,7 +345,7 @@ export async function hasSymlinkParent(currentPath: string): Promise<boolean> {
// Recurse up the directory tree
return await hasSymlinkParent(parentDirectory);
} catch (error) {
console.error('Error checking symlinks:', error);
traceError('Error checking symlinks:', error);
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
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');
}

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