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

Rename logging methods #15654

Merged
merged 7 commits into from
May 3, 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/codespaces/codeSpacesServerSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-use-before-define */

import { inject, injectable } from 'inversify';
import { traceError } from '../platform/logging';
import { logger } from '../platform/logging';
import {
IJupyterServerProviderRegistry,
IJupyterServerUriStorage,
Expand Down Expand Up @@ -41,7 +41,7 @@ export class CodespacesJupyterServerSelector {
try {
await this.jupyterConnection.validateRemoteUri(provider);
} catch (err) {
traceError(`Error in validating the Remote Uri ${provider.id}.${provider.handle}`, err);
logger.error(`Error in validating the Remote Uri ${provider.id}.${provider.handle}`, err);
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/extension.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from './platform/common/types';
import { Common } from './platform/common/utils/localize';
import { IServiceContainer, IServiceManager } from './platform/ioc/types';
import { initializeLoggers as init, traceError } from './platform/logging';
import { initializeLoggers as init, logger } from './platform/logging';
import { getJupyterOutputChannel } from './standalone/devTools/jupyterOutputChannel';
import { isUsingPylance } from './standalone/intellisense/notebookPythonPathService';
import { noop } from './platform/common/utils/misc';
Expand Down Expand Up @@ -148,15 +148,15 @@ export function handleError(
notifyUser(Common.handleExtensionActivationError);
// Possible logger hasn't initialized either.
console.error('extension activation failed', ex);
traceError('extension activation failed', ex);
logger.error('extension activation failed', ex);
sendErrorTelemetry(ex, startupDurations, stopWatch);
}

function notifyUser(msg: string) {
try {
window.showErrorMessage(msg).then(noop, noop);
} catch (ex) {
traceError('failed to notify user', ex);
logger.error('failed to notify user', ex);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/extension.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import './platform/logging';

import { commands, env, ExtensionMode, UIKind, workspace, type OutputChannel } from 'vscode';
import { buildApi, IExtensionApi } from './standalone/api';
import { setHomeDirectory, traceError } from './platform/logging';
import { logger, setHomeDirectory } from './platform/logging';
import { IAsyncDisposableRegistry, IExtensionContext, IsDevMode } from './platform/common/types';
import { IServiceContainer, IServiceManager } from './platform/ioc/types';
import { sendStartupTelemetry } from './platform/telemetry/startupTelemetry';
Expand Down Expand Up @@ -109,7 +109,7 @@ export async function activate(context: IExtensionContext): Promise<IExtensionAp
// before notifying VS Code.
durations.endActivateTime = stopWatch.elapsedTime;
handleError(ex, durations, stopWatch);
traceError('Failed to active the Jupyter Extension', ex);
logger.error('Failed to active the Jupyter Extension', ex);
// Disable this, as we don't want Python extension or any other extensions that depend on this to fall over.
// Return a dummy object, to ensure other extension do not fall over.
return {
Expand Down
4 changes: 2 additions & 2 deletions src/extension.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import './platform/logging';

import { commands, env, ExtensionMode, UIKind, workspace, type OutputChannel } from 'vscode';
import { buildApi, IExtensionApi } from './standalone/api';
import { traceError } from './platform/logging';
import { logger } from './platform/logging';
import { IAsyncDisposableRegistry, IExtensionContext, IsDevMode } from './platform/common/types';
import { IServiceContainer, IServiceManager } from './platform/ioc/types';
import { sendStartupTelemetry } from './platform/telemetry/startupTelemetry';
Expand Down Expand Up @@ -104,7 +104,7 @@ export async function activate(context: IExtensionContext): Promise<IExtensionAp
// before notifying VS Code.
durations.endActivateTime = stopWatch.elapsedTime;
handleError(ex, durations, stopWatch);
traceError('Failed to active the Jupyter Extension', ex);
logger.error('Failed to active the Jupyter Extension', ex);
// Disable this, as we don't want Python extension or any other extensions that depend on this to fall over.
// Return a dummy object, to ensure other extension do not fall over.
return {
Expand Down
8 changes: 4 additions & 4 deletions src/interactive-window/InteractiveControllerHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { InteractiveWindowView, JupyterNotebookView } from '../platform/common/c
import { IDisposableRegistry, IMemento, Resource, WORKSPACE_MEMENTO } from '../platform/common/types';
import { IInterpreterService } from '../platform/interpreter/contracts';
import { IServiceContainer } from '../platform/ioc/types';
import { traceInfoIfCI, traceWarning } from '../platform/logging';
import { logger } from '../platform/logging';
import { IInteractiveControllerHelper } from './types';
import { createInterpreterKernelSpec, getKernelId } from '../kernels/helpers';
import { getDisplayPath } from '../platform/common/platform/fs-paths';
Expand Down Expand Up @@ -87,7 +87,7 @@ export class InteractiveControllerHelper implements IInteractiveControllerHelper
return;
}
// Id may be different if the user switched controllers
traceInfoIfCI(
logger.ci(
`(onStart) Looking for controller ${k.controller.id} in ${this.controllerRegistration.all
.map((item) => `${item.kind}:${item.id}`)
.join(', ')}`
Expand Down Expand Up @@ -120,7 +120,7 @@ export class InteractiveControllerHelper implements IInteractiveControllerHelper
);
})
.catch((reason) => {
traceWarning('Failed to store kernel connection metadata', reason);
logger.warn('Failed to store kernel connection metadata', reason);
});
}

Expand Down Expand Up @@ -149,7 +149,7 @@ async function createActiveInterpreterController(
const controllers = registration.addOrUpdate(metadata, [viewType]);
const controller = controllers[0]; // Should only create one because only one view type
registration.trackActiveInterpreterControllers(controllers);
traceInfoIfCI(
logger.ci(
`Active Interpreter Controller ${controller.connection.kind}:${
controller.id
} created for View ${viewType} with resource ${getDisplayPath(resource)}`
Expand Down
20 changes: 10 additions & 10 deletions src/interactive-window/InteractiveWindowController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { InteractiveWindowMode, Resource } from '../platform/common/types';
import { IInteractiveControllerHelper } from './types';
import { IVSCodeNotebookController } from '../notebooks/controllers/types';
import { SystemInfoCell, getFinishConnectMessage, getStartConnectMessage } from './systemInfoCell';
import { traceError, traceInfoIfCI, traceVerbose, traceWarning } from '../platform/logging';
import { logger } from '../platform/logging';
import { getFilePath } from '../platform/common/platform/fs-paths';
import { SysInfoReason } from '../messageTypes';
import { IDataScienceErrorHandler } from '../kernels/errors/types';
Expand Down Expand Up @@ -68,12 +68,12 @@ export class InteractiveWindowController {
// When restart finishes, rerun our initialization code
kernel.onRestarted(
async () => {
traceVerbose('Restart event handled in IW');
logger.debug('Restart event handled in IW');
this.fileInKernel = undefined;
try {
await this.setFileInKernel(kernel);
} catch (ex) {
traceError(`Failed to run initialization after restarting`);
logger.error(`Failed to run initialization after restarting`);
} finally {
this.finishSysInfoMessage(kernel, SysInfoReason.Restart);
}
Expand Down Expand Up @@ -136,26 +136,26 @@ export class InteractiveWindowController {
private async setFileInKernel(kernel: IKernel): Promise<void> {
const file = this.owner;
if (!file) {
traceInfoIfCI('Unable to run initialization for IW');
logger.ci('Unable to run initialization for IW');
return;
}
// If in perFile mode, set only once
const path = getFilePath(file);
const execution = this.kernelProvider.getKernelExecution(kernel!);
if (this.mode === 'perFile' && !this.fileInKernel) {
traceVerbose(`Initializing __file__ in setFileInKernel with ${file} for mode ${this.mode}`);
logger.debug(`Initializing __file__ in setFileInKernel with ${file} for mode ${this.mode}`);
this.fileInKernel = file;
await execution.executeHidden(`__file__ = '${path.replace(/\\/g, '\\\\')}'`);
} else if (
(!this.fileInKernel || this.fileInKernel.toString() !== file.toString()) &&
this.mode !== 'perFile'
) {
traceVerbose(`Initializing __file__ in setFileInKernel with ${file} for mode ${this.mode}`);
logger.debug(`Initializing __file__ in setFileInKernel with ${file} for mode ${this.mode}`);
// Otherwise we need to reset it every time
this.fileInKernel = file;
await execution.executeHidden(`__file__ = '${path.replace(/\\/g, '\\\\')}'`);
} else {
traceVerbose(
logger.debug(
`Not Initializing __file__ in setFileInKernel with ${path} for mode ${this.mode} currently ${this.fileInKernel}`
);
}
Expand Down Expand Up @@ -203,7 +203,7 @@ export class InteractiveWindowController {
this.systemInfoCell
.updateMessage(message)
.catch((error) =>
traceWarning(`could not update info cell with message: "${message}", error: ${error}`)
logger.warn(`could not update info cell with message: "${message}", error: ${error}`)
);
}
}
Expand All @@ -218,7 +218,7 @@ export class InteractiveWindowController {
this.systemInfoCell
?.updateMessage(message)
.catch((error) =>
traceWarning(`System info message was not updated: "${message}" because of error: ${error}`)
logger.warn(`System info message was not updated: "${message}" because of error: ${error}`)
);
this.systemInfoCell = undefined;
}
Expand All @@ -230,7 +230,7 @@ export class InteractiveWindowController {
this.systemInfoCell
?.updateMessage(message)
.catch((error) =>
traceWarning(`System info message was not updated: "${message}" because of error: ${error}`)
logger.warn(`System info message was not updated: "${message}" because of error: ${error}`)
);
this.systemInfoCell = undefined;
}
Expand Down
10 changes: 5 additions & 5 deletions src/interactive-window/commands/commandRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { IExtensionSyncActivationService } from '../../platform/activation/types
import { ExportFormat, IFileConverter } from '../../notebooks/export/types';
import { openAndShowNotebook } from '../../platform/common/utils/notebooks';
import { JupyterInstallError } from '../../platform/errors/jupyterInstallError';
import { traceError, traceInfo, traceVerbose } from '../../platform/logging';
import { logger } from '../../platform/logging';
import { generateCellsFromDocument } from '../editor-integration/cellFactory';
import { IDataScienceErrorHandler } from '../../kernels/errors/types';
import { INotebookEditorProvider } from '../../notebooks/types';
Expand Down Expand Up @@ -391,7 +391,7 @@ export class CommandRegistry implements IDisposable, IExtensionSyncActivationSer
if (iw && iw.notebookDocument) {
const kernel = this.kernelProvider.get(iw.notebookDocument);
if (kernel) {
traceVerbose(`Interrupt kernel due to debug stop of IW ${uri.toString()}`);
logger.debug(`Interrupt kernel due to debug stop of IW ${uri.toString()}`);
// If we have a matching iw, then stop current execution
await kernel.interrupt();
}
Expand Down Expand Up @@ -578,7 +578,7 @@ export class CommandRegistry implements IDisposable, IExtensionSyncActivationSer
result = await promise();
return result;
} catch (err) {
traceError('listenForErrors', err as any);
logger.error('listenForErrors', err as any);
this.dataScienceErrorHandler.handleError(err).then(noop, noop);
}
return result;
Expand Down Expand Up @@ -678,15 +678,15 @@ export class CommandRegistry implements IDisposable, IExtensionSyncActivationSer

private async expandAllCells(uri?: Uri) {
const interactiveWindow = this.interactiveWindowProvider.getInteractiveWindowWithNotebook(uri);
traceInfo(`Expanding all cells in interactive window with uri ${interactiveWindow?.notebookUri}`);
logger.info(`Expanding all cells in interactive window with uri ${interactiveWindow?.notebookUri}`);
if (interactiveWindow) {
await interactiveWindow.expandAllCells();
}
}

private async collapseAllCells(uri?: Uri) {
const interactiveWindow = this.interactiveWindowProvider.getInteractiveWindowWithNotebook(uri);
traceInfo(`Collapsing all cells in interactive window with uri ${interactiveWindow?.notebookUri}`);
logger.info(`Collapsing all cells in interactive window with uri ${interactiveWindow?.notebookUri}`);
if (interactiveWindow) {
await interactiveWindow.collapseAllCells();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type * as nbformat from '@jupyterlab/nbformat';
import { inject, injectable, named } from 'inversify';
import { DebugConfiguration, Disposable, NotebookDocument } from 'vscode';
import { IPythonApiProvider } from '../../platform/api/types';
import { traceInfo, traceInfoIfCI, traceWarning } from '../../platform/logging';
import { logger } from '../../platform/logging';
import { IPlatformService } from '../../platform/common/platform/types';
import { IConfigurationService } from '../../platform/common/types';
import { DataScience } from '../../platform/common/utils/localize';
Expand Down Expand Up @@ -76,7 +76,7 @@ export class InteractiveWindowDebugger implements IInteractiveWindowDebugger {
const notebook = kernel.notebook;
const config = this.configs.get(notebook);
if (config) {
traceInfo('stop debugging');
logger.info('stop debugging');

// Tell our debug service to shutdown if possible
this.debuggingActive = false;
Expand All @@ -93,7 +93,7 @@ export class InteractiveWindowDebugger implements IInteractiveWindowDebugger {
public async updateSourceMaps(hashes: IFileGeneratedCodes[]): Promise<void> {
// Make sure that we have an active debugging session at this point
if (this.debugService.activeDebugSession && this.debuggingActive) {
traceInfoIfCI(`Sending debug request for source map`);
logger.ci(`Sending debug request for source map`);
await Promise.all(
hashes.map(async (fileHash) => {
if (this.debuggingActive) {
Expand Down Expand Up @@ -134,14 +134,14 @@ export class InteractiveWindowDebugger implements IInteractiveWindowDebugger {
kernel: IKernel,
extraConfig: Partial<DebugConfiguration>
) {
traceInfo('start debugging');
logger.info('start debugging');
if (!kernel.session?.kernel) {
return;
}
// Try to connect to this notebook
const config = await this.connect(kernel, extraConfig);
if (config) {
traceInfo('connected to notebook during debugging');
logger.info('connected to notebook during debugging');

this.debuggingActive = await startCommand(config);

Expand All @@ -157,9 +157,9 @@ export class InteractiveWindowDebugger implements IInteractiveWindowDebugger {
telemetryName: Telemetry.InteractiveWindowDebugSetupCodeFailure
});
if (importResults.some((item) => item.output_type === 'error')) {
traceWarning(`${this.debuggerPackage} not found in path.`);
logger.warn(`${this.debuggerPackage} not found in path.`);
} else {
traceInfo(`import startup: ${getPlainTextOrStreamOutput(importResults)}`);
logger.info(`import startup: ${getPlainTextOrStreamOutput(importResults)}`);
}

// After attach initially disable debugging
Expand All @@ -182,7 +182,7 @@ export class InteractiveWindowDebugger implements IInteractiveWindowDebugger {
...extraConfig
};
}
traceInfo('enable debugger attach');
logger.info('enable debugger attach');

// Append any specific debugger paths that we have
await this.appendDebuggerPaths(kernel);
Expand Down Expand Up @@ -276,7 +276,7 @@ export class InteractiveWindowDebugger implements IInteractiveWindowDebugger {
}
)
: [];
traceInfo(`Appending paths: ${getPlainTextOrStreamOutput(result)}`);
logger.info(`Appending paths: ${getPlainTextOrStreamOutput(result)}`);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { IDebuggingDelegate, IKernelDebugAdapter } from '../../../notebooks/debugger/debuggingTypes';
import { cellDebugSetup } from '../../../notebooks/debugger/helper';
import { createDeferred } from '../../../platform/common/utils/async';
import { traceVerbose } from '../../../platform/logging';
import { logger } from '../../../platform/logging';
import { sendTelemetryEvent } from '../../../telemetry';
import { getInteractiveCellMetadata } from '../../helpers';

Expand All @@ -34,7 +34,7 @@ export class DebugCellController implements IDebuggingDelegate {
}

private trace(tag: string, msg: string) {
traceVerbose(`[Debug-IW] ${tag}: ${msg}`);
logger.debug(`[Debug-IW] ${tag}: ${msg}`);
}

public async willSendEvent(msg: DebugProtocol.Event): Promise<boolean> {
Expand Down
Loading
Loading