diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.ts b/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.ts index 2b8830d228c..b6a1b14b9ba 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.ts @@ -66,7 +66,7 @@ class NotebookKernelDetection extends Disposable implements IWorkbenchContributi }); if (shouldStartDetection && !this._detectionMap.has(notebookType)) { - this._notebookLoggingService.log('KernelDetection', `start extension activation for ${notebookType}`); + this._notebookLoggingService.debug('KernelDetection', `start extension activation for ${notebookType}`); const task = this._notebookKernelService.registerNotebookKernelDetectionTask({ notebookType: notebookType }); @@ -88,7 +88,7 @@ class NotebookKernelDetection extends Disposable implements IWorkbenchContributi const taskToDelete: string[] = []; for (const [notebookType, task] of this._detectionMap) { if (this._extensionService.activationEventIsDone(`onNotebook:${notebookType}`)) { - this._notebookLoggingService.log('KernelDetection', `finish extension activation for ${notebookType}`); + this._notebookLoggingService.debug('KernelDetection', `finish extension activation for ${notebookType}`); taskToDelete.push(notebookType); task.dispose(); } diff --git a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts index 59ae47fc1fb..3032a8b99be 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -892,12 +892,6 @@ configurationRegistry.registerConfiguration({ type: 'boolean', tags: ['notebookLayout'], default: false - }, - [NotebookSetting.logging]: { - markdownDescription: nls.localize('notebook.logging', "Enable logging for notebook support."), - type: 'boolean', - tags: ['notebookLayout'], - default: false } } }); diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts index af010178238..fcb61e4b115 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts @@ -1499,15 +1499,15 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD private async _warmupWithMarkdownRenderer(viewModel: NotebookViewModel, viewState: INotebookEditorViewState | undefined) { - this.logService.log('NotebookEditorWidget', 'warmup ' + this.viewModel?.uri.toString()); + this.logService.debug('NotebookEditorWidget', 'warmup ' + this.viewModel?.uri.toString()); await this._resolveWebview(); - this.logService.log('NotebookEditorWidget', 'warmup - webview resolved'); + this.logService.debug('NotebookEditorWidget', 'warmup - webview resolved'); // make sure that the webview is not visible otherwise users will see pre-rendered markdown cells in wrong position as the list view doesn't have a correct `top` offset yet this._webview!.element.style.visibility = 'hidden'; // warm up can take around 200ms to load markdown libraries, etc. await this._warmupViewport(viewModel, viewState); - this.logService.log('NotebookEditorWidget', 'warmup - viewport warmed up'); + this.logService.debug('NotebookEditorWidget', 'warmup - viewport warmed up'); // todo@rebornix @mjbvz, is this too complicated? @@ -1526,7 +1526,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD this._list.scrollTop = viewState?.scrollPosition?.top ?? 0; this._debug('finish initial viewport warmup and view state restore.'); this._webview!.element.style.visibility = 'visible'; - this.logService.log('NotebookEditorWidget', 'warmup - list view model attached, set to visible'); + this.logService.debug('NotebookEditorWidget', 'warmup - list view model attached, set to visible'); } private async _warmupViewport(viewModel: NotebookViewModel, viewState: INotebookEditorViewState | undefined) { diff --git a/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.ts b/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.ts index 451e9e6b1bd..7256ad1d404 100644 --- a/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.ts +++ b/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.ts @@ -44,10 +44,10 @@ export class NotebookKernelHistoryService extends Disposable implements INoteboo const selectedKernel = allAvailableKernels.selected; // We will suggest the only kernel const suggested = allAvailableKernels.all.length === 1 ? allAvailableKernels.all[0] : undefined; - this._notebookLoggingService.log('History', `getMatchingKernels: ${allAvailableKernels.all.length} kernels available for ${notebook.uri.path}. Selected: ${allAvailableKernels.selected?.label}. Suggested: ${suggested?.label}`); + this._notebookLoggingService.debug('History', `getMatchingKernels: ${allAvailableKernels.all.length} kernels available for ${notebook.uri.path}. Selected: ${allAvailableKernels.selected?.label}. Suggested: ${suggested?.label}`); const mostRecentKernelIds = this._mostRecentKernelsMap[notebook.viewType] ? [...this._mostRecentKernelsMap[notebook.viewType].values()] : []; const all = mostRecentKernelIds.map(kernelId => allKernels.find(kernel => kernel.id === kernelId)).filter(kernel => !!kernel) as INotebookKernel[]; - this._notebookLoggingService.log('History', `mru: ${mostRecentKernelIds.length} kernels in history, ${all.length} registered already.`); + this._notebookLoggingService.debug('History', `mru: ${mostRecentKernelIds.length} kernels in history, ${all.length} registered already.`); return { selected: selectedKernel ?? suggested, diff --git a/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.ts b/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.ts index e0037913436..67d4972cced 100644 --- a/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.ts +++ b/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.ts @@ -6,62 +6,34 @@ import * as nls from 'vs/nls'; import { Disposable } from 'vs/base/common/lifecycle'; import { INotebookLoggingService } from 'vs/workbench/contrib/notebook/common/notebookLoggingService'; -import { Registry } from 'vs/platform/registry/common/platform'; -import { IOutputChannelRegistry, IOutputService, Extensions as OutputExt, IOutputChannel } from 'vs/workbench/services/output/common/output'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { ILogger, ILoggerService } from 'vs/platform/log/common/log'; +import { joinPath } from 'vs/base/common/resources'; +import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +const logChannelId = 'notebook.rendering'; export class NotebookLoggingService extends Disposable implements INotebookLoggingService { _serviceBrand: undefined; static ID: string = 'notebook'; - private _enabled: boolean = false; - private _outputChannel: IOutputChannel | undefined = undefined; + private readonly _logger: ILogger; constructor( - @IOutputService private readonly _outputService: IOutputService, - @IConfigurationService private readonly _configurationService: IConfigurationService + @ILoggerService loggerService: ILoggerService, + @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, ) { super(); - - this._enabled = this._configurationService.getValue('notebook.logging'); - - this._register(this._configurationService.onDidChangeConfiguration(e => { - if (e.affectsConfiguration('notebook.logging')) { - this._enabled = this._configurationService.getValue('notebook.logging'); - } - })); + const logsPath = joinPath(environmentService.windowLogsPath, 'notebook.rendering.log'); + this._logger = this._register(loggerService.createLogger(logsPath, { id: logChannelId, name: nls.localize('renderChannelName', "Notebook rendering") })); } - private _getOrCreateOutputChannel(): IOutputChannel { - if (this._outputChannel) { - return this._outputChannel; - } - const channel = this._outputService.getChannel(NotebookLoggingService.ID); - - if (channel) { - this._outputChannel = channel; - return channel; - } - const outputChannelRegistry = Registry.as(OutputExt.OutputChannels); - outputChannelRegistry.registerChannel({ id: NotebookLoggingService.ID, label: nls.localize('notebook.log', "Notebooks"), log: false }); - - this._outputChannel = this._outputService.getChannel(NotebookLoggingService.ID); - if (!this._outputChannel) { - throw new Error('output channel not found'); - } - - return this._outputChannel; + debug(category: string, output: string): void { + this._logger.debug(`[${category}] ${output}`); } - log(category: string, output: string): void { - if (!this._enabled) { - return; - } - - const channel = this._getOrCreateOutputChannel(); - channel.append(`[${category}] ${output}\n`); + info(category: string, output: string): void { + this._logger.info(`[${category}] ${output}`); } } diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts index 9a97bf2c11d..72a0b05d8b5 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts @@ -27,7 +27,6 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs'; import { IFileService } from 'vs/platform/files/common/files'; -import { ILogger, ILoggerService, ILogService } from 'vs/platform/log/common/log'; import { IOpenerService, matchesScheme, matchesSomeScheme } from 'vs/platform/opener/common/opener'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { editorFindMatch, editorFindMatchHighlight } from 'vs/platform/theme/common/colorRegistry'; @@ -52,6 +51,7 @@ import { FromWebviewMessage, IAckOutputHeight, IClickedDataUrlMessage, ICodeBloc import { IPathService } from 'vs/workbench/services/path/common/pathService'; import { ITextEditorOptions } from 'vs/platform/editor/common/editor'; import { EditorInput } from 'vs/workbench/common/editor/editorInput'; +import { INotebookLoggingService } from 'vs/workbench/contrib/notebook/common/notebookLoggingService'; const LINE_COLUMN_REGEX = /:([\d]+)(?::([\d]+))?$/; const LineQueryRegex = /line=(\d+)/; @@ -110,7 +110,6 @@ interface BacklayerWebviewOptions { readonly outputLineLimit: number; } -const logChannelId = 'notebook.rendering'; export class BackLayerWebView extends Themable { @@ -139,8 +138,6 @@ export class BackLayerWebView extends Themable { private firstInit = true; private initializeMarkupPromise?: { readonly requestId: string; readonly p: DeferredPromise; readonly isFirstInit: boolean }; - private readonly _renderLogger: ILogger; - private readonly nonce = UUID.generateUuid(); constructor( @@ -166,15 +163,11 @@ export class BackLayerWebView extends Themable { @IEditorGroupsService private readonly editorGroupService: IEditorGroupsService, @IStorageService private readonly storageService: IStorageService, @IPathService private readonly pathService: IPathService, - @ILoggerService loggerService: ILoggerService, - @ILogService logService: ILogService, + @INotebookLoggingService private readonly notebookLogService: INotebookLoggingService, @IThemeService themeService: IThemeService, ) { super(themeService); - const logsPath = joinPath(environmentService.windowLogsPath, 'notebook.rendering.log'); - this._renderLogger = this._register(loggerService.createLogger(logsPath, { id: logChannelId, name: nls.localize('renderChannelName', "Notebook rendering") })); - this._logRendererDebugMessage('Creating backlayer webview for notebook'); this.element = document.createElement('div'); @@ -222,7 +215,7 @@ export class BackLayerWebView extends Themable { } private _logRendererDebugMessage(msg: string) { - this._renderLogger.debug(`${this.documentUri} (${this.id}) - ${msg}`); + this.notebookLogService.debug('BacklayerWebview', `${this.documentUri} (${this.id}) - ${msg}`); } private _updateStyles() { diff --git a/src/vs/workbench/contrib/notebook/common/notebookLoggingService.ts b/src/vs/workbench/contrib/notebook/common/notebookLoggingService.ts index d3ee017c1b3..95d716f71b3 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookLoggingService.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookLoggingService.ts @@ -9,5 +9,6 @@ export const INotebookLoggingService = createDecorator( export interface INotebookLoggingService { readonly _serviceBrand: undefined; - log(category: string, output: string): void; + info(category: string, output: string): void; + debug(category: string, output: string): void; } diff --git a/src/vs/workbench/contrib/notebook/test/browser/notebookKernelHistory.test.ts b/src/vs/workbench/contrib/notebook/test/browser/notebookKernelHistory.test.ts index 87686ead68a..bb7e0967612 100644 --- a/src/vs/workbench/contrib/notebook/test/browser/notebookKernelHistory.test.ts +++ b/src/vs/workbench/contrib/notebook/test/browser/notebookKernelHistory.test.ts @@ -86,7 +86,8 @@ suite('NotebookKernelHistoryService', () => { }); instantiationService.stub(INotebookLoggingService, new class extends mock() { - override log() { } + override info() { } + override debug() { } }); const kernelHistoryService = instantiationService.createInstance(NotebookKernelHistoryService); @@ -136,7 +137,8 @@ suite('NotebookKernelHistoryService', () => { }); instantiationService.stub(INotebookLoggingService, new class extends mock() { - override log() { } + override info() { } + override debug() { } }); const kernelHistoryService = instantiationService.createInstance(NotebookKernelHistoryService);