Skip to content

Commit

Permalink
remove console. in production code
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Dec 17, 2024
1 parent 40fd329 commit 053bab9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
5 changes: 3 additions & 2 deletions src/client/browser/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -139,7 +140,7 @@ async function runPylance(

await client.start();
} catch (e) {
console.log(e);
traceLog(e);
}
}

Expand Down Expand Up @@ -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);
}
});
}
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); // keep due to circular dependencies
}
});
}
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,
)} `,
);
); // keep due to circular dependencies
}
}

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;
}
}
23 changes: 10 additions & 13 deletions src/client/testing/testController/pytest/pytestExecutionAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 053bab9

Please sign in to comment.