This commit is contained in:
Don Jayamanne 2024-05-02 07:40:51 +10:00 коммит произвёл GitHub
Родитель cc7eaf09d3
Коммит 93a221ddd8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
18 изменённых файлов: 63 добавлений и 53 удалений

Просмотреть файл

@ -290,9 +290,9 @@ async function activateLegacy(
// `IConfigurationService` may depend any of the registered types, so doing it after all registrations are finished.
// XXX Move this *after* abExperiments is activated?
const settings = configuration.getSettings();
setLoggingLevel(settings.logging.level);
setLoggingLevel(settings.logging.level, settings.logging.widgets);
settings.onDidChange(() => {
setLoggingLevel(settings.logging.level);
setLoggingLevel(settings.logging.level, settings.logging.widgets);
});
// "initialize" "services"

Просмотреть файл

@ -249,9 +249,9 @@ async function activateLegacy(
// `IConfigurationService` may depend any of the registered types, so doing it after all registrations are finished.
// XXX Move this *after* abExperiments is activated?
const settings = configuration.getSettings();
setLoggingLevel(settings.logging.level);
setLoggingLevel(settings.logging.level, settings.logging.widgets);
settings.onDidChange(() => {
setLoggingLevel(settings.logging.level);
setLoggingLevel(settings.logging.level, settings.logging.widgets);
});
// "initialize" "services"

Просмотреть файл

@ -25,7 +25,14 @@ import {
} from '../platform/common/constants';
import { WrappedError } from '../platform/errors/types';
import { splitLines } from '../platform/common/helpers';
import { traceInfo, traceInfoIfCI, traceError, traceVerbose, traceWarning } from '../platform/logging';
import {
traceInfo,
traceInfoIfCI,
traceError,
traceVerbose,
traceWarning,
traceVerboseWidgets
} from '../platform/logging';
import { getDisplayPath, getFilePath } from '../platform/common/platform/fs-paths';
import { Resource, IDisposable, IDisplayOptions } from '../platform/common/types';
import { createDeferred, raceTimeout, raceTimeoutError } from '../platform/common/utils/async';
@ -852,7 +859,7 @@ abstract class BaseKernel implements IBaseKernel {
);
const newVersion = (this._ipywidgetsVersion = isVersion7 ? 7 : isVersion8 ? 8 : undefined);
traceVerbose(`Determined IPyWidgets Version as ${newVersion}`);
traceVerboseWidgets(`Determined IPyWidgets Version as ${newVersion}`);
// If user does not have ipywidgets installed, then this event will never get fired.
this._ipywidgetsVersion == newVersion;
this._onIPyWidgetVersionResolved.fire(newVersion);

Просмотреть файл

@ -246,7 +246,7 @@ export class InterpreterSpecificKernelSpecsFinder extends DisposableBase {
isDefaultKernelSpec(jupyterKernelSpec)
) {
traceVerbose(
`Hiding default KernelSpec '${jupyterKernelSpec.name}', ${getDisplayPath(
`Hiding default KernelSpec ${getDisplayPath(
jupyterKernelSpec.argv[0]
)} for interpreter ${getDisplayPath(
jupyterKernelSpec.interpreterPath

Просмотреть файл

@ -195,8 +195,6 @@ export class JupyterPaths {
if (!dataDir.has(sitePath)) {
dataDir.set(sitePath, dataDir.size);
}
} else {
traceWarning(`Got a non-existent Jupyter Data Dir ${sitePath}`);
}
} else {
traceWarning(`Got an empty Jupyter Data Dir from ${interpreter.id}, stderr = ${result.stderr}`);

Просмотреть файл

@ -134,10 +134,6 @@ export class KernelEnvironmentVariablesService {
this.envVarsService.mergeVariables(customEnvVars, mergedVars); // custom vars win over all.
}
traceVerbose(
`Kernel Env Variables for ${kernelSpec.specFile || kernelSpec.name}, PATH value is ${mergedVars.PATH}`
);
// env variables in kernelSpecs can contain variables that need to be substituted
for (const [key, value] of Object.entries(kernelSpecVariablesRequiringSubstitution)) {
mergedVars[key] = substituteEnvVars(key, value, mergedVars);

Просмотреть файл

@ -4,7 +4,7 @@
import type { KernelMessage } from '@jupyterlab/services';
import { Event, EventEmitter, NotebookDocument, Uri, commands, env, window } from 'vscode';
import { STANDARD_OUTPUT_CHANNEL, WIDGET_VERSION_NON_PYTHON_KERNELS } from '../../../../platform/common/constants';
import { traceVerbose, traceError, traceInfo, traceInfoIfCI } from '../../../../platform/logging';
import { traceVerboseWidgets, traceError, traceInfoWidgets, traceInfoIfCI } from '../../../../platform/logging';
import {
IDisposableRegistry,
IOutputChannel,
@ -167,7 +167,7 @@ export class CommonMessageCoordinator {
}
// IPyWidgets scripts will not be loaded if we're unable to determine the version of IPyWidgets.
const version = await deferred.promise;
traceVerbose(`Version of IPyWidgets ${version} determined after ${stopWatch.elapsedTime / 1000}s`);
traceVerboseWidgets(`Version of IPyWidgets ${version} determined after ${stopWatch.elapsedTime / 1000}s`);
webview
.postMessage({
type: IPyWidgetMessages.IPyWidgets_Reply_Widget_Version,
@ -189,7 +189,7 @@ export class CommonMessageCoordinator {
void env.openExternal(Uri.parse(m.url));
}
if (m.type === IPyWidgetMessages.IPyWidgets_Ready) {
traceVerbose('Web view is ready to receive widget messages');
traceVerboseWidgets('Web view is ready to receive widget messages');
this.readyMessageReceived = true;
this.sendPendingWebViewMessages(webview);
}
@ -327,7 +327,7 @@ export class CommonMessageCoordinator {
const errorMsg = msg as KernelMessage.IErrorMsg;
errorMsg.content.traceback = errorMsg.content.traceback.map(stripAnsi);
}
traceInfo(`Unhandled widget kernel message: ${msg.header.msg_type} ${msg.content}`);
traceInfoWidgets(`Unhandled widget kernel message: ${msg.header.msg_type} ${msg.content}`);
this.jupyterOutput.appendLine(
DataScience.unhandledMessage(msg.header.msg_type, JSON.stringify(msg.content))
);

Просмотреть файл

@ -5,7 +5,7 @@ import type { Kernel, KernelMessage } from '@jupyterlab/services';
import uuid from 'uuid/v4';
import { Event, EventEmitter, NotebookDocument } from 'vscode';
import type { Data as WebSocketData } from 'ws';
import { traceVerbose, traceError } from '../../../../platform/logging';
import { traceVerboseWidgets, traceError } from '../../../../platform/logging';
import { Identifiers, WIDGET_MIMETYPE } from '../../../../platform/common/constants';
import { IDisposable } from '../../../../platform/common/types';
import { Deferred, createDeferred } from '../../../../platform/common/utils/async';
@ -121,7 +121,7 @@ export class IPyWidgetMessageDispatcher implements IIPyWidgetMessageDispatcher {
if (payload.category === 'error') {
traceError(`Widget Error: ${payload.message}`);
} else {
traceVerbose(`Widget Message: ${payload.message}`);
traceVerboseWidgets(`Widget Message: ${payload.message}`);
}
break;
}
@ -437,7 +437,7 @@ export class IPyWidgetMessageDispatcher implements IIPyWidgetMessageDispatcher {
return;
}
traceVerbose(`Registering commtarget ${targetName}`);
traceVerboseWidgets(`Registering commtarget ${targetName}`);
this.commTargetsRegistered.add(targetName);
this.pendingTargetNames.delete(targetName);

Просмотреть файл

@ -8,7 +8,7 @@ import { GLOBAL_MEMENTO, IConfigurationService, IMemento, WidgetCDNs } from '../
import { createDeferred, createDeferredFromPromise, Deferred } from '../../../../platform/common/utils/async';
import { Common, DataScience } from '../../../../platform/common/utils/localize';
import { noop } from '../../../../platform/common/utils/misc';
import { traceError, traceInfo, traceInfoIfCI, traceVerbose } from '../../../../platform/logging';
import { traceError, traceInfoWidgets, traceInfoIfCI, traceVerboseWidgets } from '../../../../platform/logging';
import { ConsoleForegroundColors } from '../../../../platform/logging/types';
import { sendTelemetryEvent } from '../../../../telemetry';
import { IWidgetScriptSourceProvider, WidgetScriptSource } from '../types';
@ -165,7 +165,7 @@ export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvide
moduleName: string,
moduleVersion: string
): Promise<WidgetScriptSource> {
traceInfo(
traceInfoWidgets(
`${
ConsoleForegroundColors.Green
}Searching for Widget Script ${moduleName}#${moduleVersion} using cdns ${this.cdnProviders.join(' ')}`
@ -180,7 +180,7 @@ export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvide
);
const scriptUri = uris.find((u) => u);
if (scriptUri) {
traceInfo(
traceInfoWidgets(
`${ConsoleForegroundColors.Green}Widget Script ${moduleName}#${moduleVersion} found at URI: ${scriptUri}`
);
return { moduleName, scriptUri, source: 'cdn' };
@ -200,7 +200,7 @@ export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvide
return downloadUrl;
}
} catch (ex) {
traceVerbose(`Failed downloading ${moduleName}:${moduleVersion} from ${cdn}`);
traceVerboseWidgets(`Failed downloading ${moduleName}:${moduleVersion} from ${cdn}`);
return undefined;
}
}

Просмотреть файл

@ -3,7 +3,7 @@
import type * as jupyterlabService from '@jupyterlab/services';
import { Event, EventEmitter, NotebookDocument, Uri } from 'vscode';
import { traceError, traceInfo, traceVerbose, traceWarning } from '../../../../platform/logging';
import { traceError, traceInfoWidgets, traceVerboseWidgets, traceWarning } from '../../../../platform/logging';
import { IDisposableRegistry, IConfigurationService, IDisposable } from '../../../../platform/common/types';
import { InteractiveWindowMessages, IPyWidgetMessages } from '../../../../messageTypes';
import { sendTelemetryEvent, Telemetry } from '../../../../telemetry';
@ -132,7 +132,7 @@ export class IPyWidgetScriptSource {
this.kernel.onDisposed(() => this.dispose());
this.handlePendingRequests();
this.sendBaseUrl();
traceVerbose('IPyWidgetScriptSource.initialize');
traceVerboseWidgets('IPyWidgetScriptSource.initialize');
}
/**
* Sends the base url of the remote Jupyter server to the webview.
@ -189,7 +189,7 @@ export class IPyWidgetScriptSource {
private async onRequestWidgetScript(payload: { moduleName: string; moduleVersion: string; requestId: string }) {
const { moduleName, moduleVersion, requestId } = payload;
traceInfo(`${ConsoleForegroundColors.Green}Fetch Script for ${JSON.stringify(payload)}`);
traceInfoWidgets(`${ConsoleForegroundColors.Green}Fetch Script for ${JSON.stringify(payload)}`);
await this.sendWidgetSource(moduleName, moduleVersion, requestId).catch((ex) =>
traceError('Failed to send widget sources upon ready', ex)
);
@ -221,7 +221,7 @@ export class IPyWidgetScriptSource {
let widgetSource: WidgetScriptSource = { moduleName, requestId };
try {
traceInfo(`${ConsoleForegroundColors.Green}Fetch Script for ${moduleName}`);
traceInfoWidgets(`${ConsoleForegroundColors.Green}Fetch Script for ${moduleName}`);
widgetSource = await this.scriptProvider.getWidgetScriptSource(moduleName, moduleVersion);
// If we have a widget source from CDN, never overwrite that.
if (this.widgetSources.get(widgetSource.moduleName)?.source !== 'cdn') {
@ -231,7 +231,7 @@ export class IPyWidgetScriptSource {
traceError('Failed to get widget source due to an error', ex);
sendTelemetryEvent(Telemetry.HashedIPyWidgetScriptDiscoveryError);
} finally {
traceInfo(
traceInfoWidgets(
`${ConsoleForegroundColors.Green}Script for ${moduleName}, is ${widgetSource.scriptUri} from ${widgetSource.source}`
);
// Send to UI (even if there's an error) continues instead of hanging while waiting for a response.

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { traceError, traceVerbose, traceWarning } from '../../../../platform/logging';
import { traceError, traceVerboseWidgets, traceWarning } from '../../../../platform/logging';
import { WidgetCDNs, IConfigurationService } from '../../../../platform/common/types';
import { sendTelemetryEvent, Telemetry } from '../../../../telemetry';
import { getTelemetrySafeHashedString } from '../../../../platform/telemetry/helpers';
@ -102,7 +102,7 @@ export class IPyWidgetScriptSourceProvider extends DisposableBase implements IWi
.join(', ')}`
);
} else {
traceVerbose(
traceVerboseWidgets(
`Script source for Widget ${moduleName}@${moduleVersion} was found from source ${found.source} and ${found.scriptUri}`
);
}

Просмотреть файл

@ -5,7 +5,7 @@ import type * as nbformat from '@jupyterlab/nbformat';
import * as path from '../../../../platform/vscode-path/path';
import { ExtensionMode, Uri } from 'vscode';
import { IExtensionContext } from '../../../../platform/common/types';
import { traceError, traceInfoIfCI, traceVerbose } from '../../../../platform/logging';
import { traceError, traceInfoIfCI, traceVerboseWidgets } from '../../../../platform/logging';
import { executeSilently, isPythonKernelConnection } from '../../../../kernels/helpers';
import { IKernel, RemoteKernelConnectionMetadata } from '../../../../kernels/types';
import { IIPyWidgetScriptManager } from '../types';
@ -111,7 +111,7 @@ export class RemoteIPyWidgetScriptManager extends BaseIPyWidgetScriptManager imp
return [];
}
try {
traceVerbose(`Widget Outputs include, ${output.text}`);
traceVerboseWidgets(`Widget Outputs include, ${output.text}`);
// Value will be an array of the form `['xyz', 'abc']`
const items = (output.text as string)
.trim()

Просмотреть файл

@ -4,7 +4,7 @@
import { inject, injectable } from 'inversify';
import { NotebookDocument, Disposable, NotebookEditor, Uri, EventEmitter, workspace, window } from 'vscode';
import { dispose } from '../../platform/common/utils/lifecycle';
import { traceVerbose } from '../../platform/logging';
import { traceVerboseWidgets } from '../../platform/logging';
import { getDisplayPath } from '../../platform/common/platform/fs-paths';
import { IDisposableRegistry, IDisposable } from '../../platform/common/types';
import { IServiceContainer } from '../../platform/ioc/types';
@ -142,7 +142,7 @@ export class NotebookIPyWidgetCoordinator implements IExtensionSyncActivationSer
}
const notebook = editor.notebook;
if (!controller) {
traceVerbose(
traceVerboseWidgets(
`No controller, hence notebook communications cannot be initialized for editor ${getDisplayPath(
editor.notebook.uri
)}`

Просмотреть файл

@ -111,6 +111,7 @@ export type LoggingLevelSettingType = 'off' | 'error' | 'warn' | 'info' | 'debug
export interface ILoggingSettings {
readonly level: LoggingLevelSettingType | 'off';
readonly widgets?: LoggingLevelSettingType | 'off';
}
export interface IExperiments {

Просмотреть файл

@ -196,9 +196,7 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi
traceVerbose(
`Got env vars from Python Ext in ${stopWatch.elapsedTime}ms for ${getDisplayPath(
environment.path
)}, with env var count ${Object.keys(env || {}).length}. \n PATH value is ${
env.PATH
} and \n Path value is ${env.Path}`
)}, with env var count ${Object.keys(env || {}).length}.`
);
} else if (envType === EnvironmentType.Conda) {
// We must get activated env variables for Conda env, if not running stuff against conda will not work.
@ -290,11 +288,6 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi
this.envVarsService.prependPath(env, path.dirname(environment.executable.uri.fsPath));
}
traceVerbose(
`Activated Env Variables for ${getDisplayPath(environment.path)}, \n PATH value is ${
env.PATH
} and \n Path value is ${env.Path}`
);
return env;
}
}

Просмотреть файл

@ -37,7 +37,12 @@ const logLevelMap: Map<string | undefined, LogLevel> = new Map([
]);
let globalLoggingLevel: LogLevel = LogLevel.Debug;
export function setLoggingLevel(level?: LoggingLevelSettingType | number): void {
let _enabledWidgetLogging: LoggingLevelSettingType = 'off';
export function setLoggingLevel(
level?: LoggingLevelSettingType | number,
enabledWidgetLogging?: LoggingLevelSettingType
): void {
_enabledWidgetLogging = enabledWidgetLogging || 'off';
globalLoggingLevel = typeof level === 'number' ? level : logLevelMap.get(level) ?? LogLevel.Error;
}
@ -127,12 +132,22 @@ export function traceInfo(message: string, ...args: Arguments): void {
loggers.forEach((l) => l.traceInfo(message, ...args));
}
}
export function traceInfoWidgets(message: string, ...args: Arguments): void {
if (_enabledWidgetLogging !== 'off' && globalLoggingLevel <= LogLevel.Info) {
loggers.forEach((l) => l.traceInfo(message, ...args));
}
}
export function traceVerbose(message: string, ...args: Arguments): void {
if (globalLoggingLevel <= LogLevel.Trace) {
loggers.forEach((l) => l.traceVerbose(message, ...args));
}
}
export function traceVerboseWidgets(message: string, ...args: Arguments): void {
if (_enabledWidgetLogging !== 'off' && globalLoggingLevel <= LogLevel.Trace) {
loggers.forEach((l) => l.traceVerbose(message, ...args));
}
}
export function traceInfoIfCI(msg: () => [message: string, ...args: string[]] | string): void;
export function traceInfoIfCI(message: string, ...args: string[]): void;
export function traceInfoIfCI(arg1: any, ...args: Arguments): void {

Просмотреть файл

@ -17,7 +17,7 @@ import {
} from '../notebook/helper';
import { initialize } from '../../initialize';
import { JVSC_EXTENSION_ID, PYTHON_LANGUAGE } from '../../../platform/common/constants';
import { traceInfo } from '../../../platform/logging';
import { traceInfoWidgets } from '../../../platform/logging';
import { IKernel, IKernelProvider, isLocalConnection } from '../../../kernels/types';
import { getTelemetrySafeHashedString } from '../../../platform/telemetry/helpers';
import { IFileSystem } from '../../../platform/common/platform/types';
@ -45,7 +45,7 @@ suite('IPyWidget Script Manager @widgets', function () {
let fs: IFileSystem;
let context: IExtensionContext;
suiteSetup(async function () {
traceInfo('Suite Setup');
traceInfoWidgets('Suite Setup');
api = await initialize();
await closeNotebooks();
await startJupyterServer();
@ -97,18 +97,18 @@ suite('IPyWidget Script Manager @widgets', function () {
kernel = kernelProvider.get(notebook)!;
scriptManager = widgetScriptManagerFactory.getOrCreate(kernel);
traceInfo('Suite Setup (completed)');
traceInfoWidgets('Suite Setup (completed)');
});
setup(async function () {
traceInfo(`Starting Test ${this.currentTest?.title}`);
traceInfoWidgets(`Starting Test ${this.currentTest?.title}`);
});
teardown(async function () {
traceInfo(`Ended Test ${this.currentTest?.title}`);
traceInfoWidgets(`Ended Test ${this.currentTest?.title}`);
if (this.currentTest?.isFailed()) {
await captureScreenShot(this);
}
traceInfo(`Ended Test (completed) ${this.currentTest?.title}`);
traceInfoWidgets(`Ended Test (completed) ${this.currentTest?.title}`);
});
suiteTeardown(() => closeNotebooksAndCleanUpAfterTests(disposables));
test('Returns the right base Url', async function () {

Просмотреть файл

@ -13,7 +13,7 @@ import { WIDGET_MIMETYPE } from '../../../platform/common/constants';
import { dispose } from '../../../platform/common/utils/lifecycle';
import { IDisposable } from '../../../platform/common/types';
import { noop } from '../../../platform/common/utils/misc';
import { traceVerbose } from '../../../platform/logging';
import { traceVerboseWidgets } from '../../../platform/logging';
type WidgetData = {
model_id: string;
@ -140,10 +140,10 @@ export class IPyWidgetRendererComms implements IExtensionSyncActivationService {
// }
const version = kernel?.ipywidgetsVersion; // || versionInWidgetState;
if (kernel?.ipywidgetsVersion) {
traceVerbose(`IPyWidget version in Kernel is ${kernel?.ipywidgetsVersion}.`);
traceVerboseWidgets(`IPyWidget version in Kernel is ${kernel?.ipywidgetsVersion}.`);
}
// if (versionInWidgetState) {
// traceVerbose(`IPyWidget version in Kernel is ${versionInWidgetState}.`);
// traceVerboseWidgets(`IPyWidget version in Kernel is ${versionInWidgetState}.`);
// }
// if (kernel?.ipywidgetsVersion && versionInWidgetState) {
// traceWarning(