Skip to content

Commit

Permalink
Use LogOutputWindow (#7805)
Browse files Browse the repository at this point in the history
Extension side of dotnet/razor#11226
  • Loading branch information
ryzngard authored Nov 20, 2024
1 parent 5b414fa commit bf8af14
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 190 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)

# 2.58.x
* Update Razor to 9.0.0-preview.24569.4 (PR: [#7805](https://github.com/dotnet/vscode-csharp/pull/7805))
* Allow logging level to be changed in rzls (#11228) (PR: [#11228](https://github.com/dotnet/razor/pull/11228))
* [Fuse] bind-Value:attribute support (#11214) (PR: [#11214](https://github.com/dotnet/razor/pull/11214))
* Handle skipped trivia in the C# tokenizer (#11207) (PR: [#11207](https://github.com/dotnet/razor/pull/11207))
* Add support for refreshing opened source generated files (PR: [#7791](https://github.com/dotnet/vscode-csharp/pull/7791))
* Update Roslyn to 4.13.0-2.24569.1 (PR: [#7791](https://github.com/dotnet/vscode-csharp/pull/7791))
* Support unbound generic types in 'nameof' operator. (PR: [#75368](https://github.com/dotnet/roslyn/pull/75368))
Expand Down
3 changes: 0 additions & 3 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"Cannot load Razor language server because the directory was not found: '{0}'": "Cannot load Razor language server because the directory was not found: '{0}'",
"Razor Log": "Razor Log",
"Could not find '{0}' in or above '{1}'.": "Could not find '{0}' in or above '{1}'.",
"Invalid razor.server.trace setting. Defaulting to '{0}'": "Invalid razor.server.trace setting. Defaulting to '{0}'",
"Could not find Razor Language Server executable '{0}' within directory": "Could not find Razor Language Server executable '{0}' within directory",
"Server failed to start after retrying 5 times.": "Server failed to start after retrying 5 times.",
"Razor Language Server failed to start unexpectedly, please check the 'Razor Log' and report an issue.": "Razor Language Server failed to start unexpectedly, please check the 'Razor Log' and report an issue.",
Expand All @@ -72,8 +71,6 @@
"Tried to bind on notification logic while server is not started.": "Tried to bind on notification logic while server is not started.",
"Cannot stop Razor Language Server as it is already stopped.": "Cannot stop Razor Language Server as it is already stopped.",
"Razor Language Server failed to stop correctly, please check the 'Razor Log' and report an issue.": "Razor Language Server failed to stop correctly, please check the 'Razor Log' and report an issue.",
"Would you like to restart the Razor Language Server to enable the Razor trace configuration change?": "Would you like to restart the Razor Language Server to enable the Razor trace configuration change?",
"Restart": "Restart",
"Razor HTML Preview": "Razor HTML Preview",
"Unexpected error when attaching to HTML preview window.": "Unexpected error when attaching to HTML preview window.",
"Razor HTML copied to clipboard": "Razor HTML copied to clipboard",
Expand Down
18 changes: 1 addition & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"defaults": {
"roslyn": "4.13.0-2.24569.1",
"omniSharp": "1.39.11",
"razor": "9.0.0-preview.24565.1",
"razor": "9.0.0-preview.24569.4",
"razorOmnisharp": "7.0.0-preview.23363.1",
"xamlTools": "17.13.35513.19"
},
Expand Down Expand Up @@ -1505,22 +1505,6 @@
"description": "%configuration.razor.languageServer.debug%",
"order": 90
},
"razor.server.trace": {
"scope": "window",
"type": "string",
"enum": [
"Trace",
"Debug",
"Information",
"Warning",
"Error",
"Critical",
"None"
],
"order": 90,
"default": "Information",
"description": "%configuration.razor.server.trace%"
},
"razor.languageServer.forceRuntimeCodeGeneration": {
"type": "boolean",
"scope": "machine-overridable",
Expand Down
32 changes: 0 additions & 32 deletions src/razor/src/configurationChangeListener.ts

This file was deleted.

11 changes: 5 additions & 6 deletions src/razor/src/diagnostics/reportIssuePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import * as vscode from 'vscode';
import { RazorLogger } from '../razorLogger';
import { LogLevel } from '../logLevel';
import { ReportIssueCreator } from './reportIssueCreator';
import { ReportIssueDataCollector } from './reportIssueDataCollector';
import { ReportIssueDataCollectorFactory } from './reportIssueDataCollectorFactory';
Expand Down Expand Up @@ -105,7 +104,7 @@ export class ReportIssuePanel {
}
});

this.traceLevelChange = this.logger.onTraceLevelChange(async () => this.update());
this.traceLevelChange = this.logger.outputChannel.onDidChangeLogLevel(async () => this.update());

this.panel.onDidDispose(() => {
if (this.traceLevelChange) {
Expand All @@ -121,7 +120,7 @@ export class ReportIssuePanel {
}

let panelBodyContent = '';
if (this.logger.logLevel.valueOf() <= LogLevel.Debug) {
if (this.logger.logLevel <= vscode.LogLevel.Debug) {
const startButtonLabel = vscode.l10n.t('Start');
const startButton = `<button onclick="startIssue()">${startButtonLabel}</button>`;
const firstLine = vscode.l10n.t('Press {0}', startButton);
Expand Down Expand Up @@ -159,9 +158,9 @@ ${privacyAnchor}
<button onclick="copyIssue()">${copyIssueContentLabel}</button>`;
} else {
const verbositySettingName = `<strong><em>${RazorLogger.verbositySetting}</em></strong>`;
const currentVerbositySettingValue = `<strong><em>${LogLevel[this.logger.logLevel]}</em></strong>`;
const neededVerbositySettingValue = `<strong><em>${LogLevel[LogLevel.Debug]}</em></strong>`;
const verbositySettingName = `<strong><em>Razor Logging Level</em></strong>`;
const currentVerbositySettingValue = `<strong><em>${vscode.LogLevel[this.logger.logLevel]}</em></strong>`;
const neededVerbositySettingValue = `<strong><em>${vscode.LogLevel[vscode.LogLevel.Debug]}</em></strong>`;

panelBodyContent =
'<p>' +
Expand Down
12 changes: 2 additions & 10 deletions src/razor/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import * as vscode from 'vscode';
import * as vscodeapi from 'vscode';
import { ExtensionContext } from 'vscode';
import { BlazorDebugConfigurationProvider } from './blazorDebug/blazorDebugConfigurationProvider';
import { CodeActionsHandler } from './codeActions/codeActionsHandler';
import { CompletionHandler } from './completion/completionHandler';
import { RazorCodeActionRunner } from './codeActions/razorCodeActionRunner';
import { RazorCodeLensProvider } from './codeLens/razorCodeLensProvider';
import { ColorPresentationHandler } from './colorPresentation/colorPresentationHandler';
import { listenToConfigurationChanges } from './configurationChangeListener';
import { RazorCSharpFeature } from './csharp/razorCSharpFeature';
import { RazorDefinitionProvider } from './definition/razorDefinitionProvider';
import { ReportIssueCommand } from './diagnostics/reportIssueCommand';
Expand All @@ -33,7 +31,6 @@ import { ProposedApisFeature } from './proposedApisFeature';
import { RazorLanguage } from './razorLanguage';
import { RazorLanguageConfiguration } from './razorLanguageConfiguration';
import { RazorLanguageServerClient } from './razorLanguageServerClient';
import { resolveRazorLanguageServerLogLevel } from './razorLanguageServerTraceResolver';
import { RazorLanguageServiceClient } from './razorLanguageServiceClient';
import { RazorLogger } from './razorLogger';
import { RazorReferenceProvider } from './reference/razorReferenceProvider';
Expand Down Expand Up @@ -71,14 +68,12 @@ export async function activate(
create: <T>() => new vscode.EventEmitter<T>(),
};

const languageServerLogLevel = resolveRazorLanguageServerLogLevel(vscodeType);
const logger = new RazorLogger(eventEmitterFactory, languageServerLogLevel);
const logger = new RazorLogger(eventEmitterFactory);

try {
const razorOptions: RazorLanguageServerOptions = resolveRazorLanguageServerOptions(
vscodeType,
languageServerDir,
languageServerLogLevel,
logger
);

Expand Down Expand Up @@ -125,6 +120,7 @@ export async function activate(
razorTelemetryReporter,
platformInfo
);

const documentSynchronizer = new RazorDocumentSynchronizer(documentManager, logger);
reportTelemetryForDocuments(documentManager, razorTelemetryReporter);
const languageConfiguration = new RazorLanguageConfiguration();
Expand Down Expand Up @@ -269,7 +265,6 @@ export async function activate(
htmlFeature.register(),
documentSynchronizer.register(),
reportIssueCommand.register(),
listenToConfigurationChanges(languageServerClient),
razorCodeActionRunner.register()
);

Expand Down Expand Up @@ -300,9 +295,6 @@ export async function activate(
localRegistrations.length = 0;
});

const provider = new BlazorDebugConfigurationProvider(logger, vscodeType);
context.subscriptions.push(vscodeType.debug.registerDebugConfigurationProvider('blazorwasm', provider));

languageServerClient.onStarted(async () => {
await documentManager.initialize();
});
Expand Down
14 changes: 0 additions & 14 deletions src/razor/src/logLevel.ts

This file was deleted.

18 changes: 7 additions & 11 deletions src/razor/src/razorLanguageServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ServerOptions } from 'vscode-languageclient/node';
import { RazorLanguage } from './razorLanguage';
import { RazorLanguageServerOptions } from './razorLanguageServerOptions';
import { resolveRazorLanguageServerOptions } from './razorLanguageServerOptionsResolver';
import { resolveRazorLanguageServerLogLevel } from './razorLanguageServerTraceResolver';
import { RazorLogger } from './razorLogger';
import { TelemetryReporter as RazorTelemetryReporter } from './telemetryReporter';
import TelemetryReporter from '@vscode/extension-telemetry';
Expand Down Expand Up @@ -56,12 +55,6 @@ export class RazorLanguageServerClient implements vscode.Disposable {
return this.client.initializeResult;
}

public updateTraceLevel() {
const languageServerLogLevel = resolveRazorLanguageServerLogLevel(this.vscodeType);
this.setupLanguageServer();
this.logger.setTraceLevel(languageServerLogLevel);
}

public onStarted(listener: () => Promise<any>) {
this.onStartedListeners.push(listener);
}
Expand Down Expand Up @@ -115,6 +108,10 @@ export class RazorLanguageServerClient implements vscode.Disposable {
await this.client.start();
this.logger.logMessage('Server started, waiting for client to be ready...');
this.isStarted = true;

// Server is ready, hook up so logging changes can be reported
this.logger.languageServerClient = this;

for (const listener of this.onStartListeners) {
await listener();
}
Expand All @@ -123,6 +120,7 @@ export class RazorLanguageServerClient implements vscode.Disposable {
resolve();

this.logger.logMessage('Server ready!');

for (const listener of this.onStartedListeners) {
await listener();
}
Expand Down Expand Up @@ -230,11 +228,9 @@ export class RazorLanguageServerClient implements vscode.Disposable {
}

private setupLanguageServer() {
const languageServerTrace = resolveRazorLanguageServerLogLevel(this.vscodeType);
const options: RazorLanguageServerOptions = resolveRazorLanguageServerOptions(
this.vscodeType,
this.languageServerDir,
languageServerTrace,
this.logger
);
this.clientOptions = {
Expand All @@ -247,8 +243,8 @@ export class RazorLanguageServerClient implements vscode.Disposable {
this.logger.logMessage(`Razor language server path: ${options.serverPath}`);

args.push('--logLevel');
args.push(options.logLevel.toString());
this.razorTelemetryReporter.reportTraceLevel(options.logLevel);
args.push(this.logger.logLevelForRZLS.toString());
this.razorTelemetryReporter.reportTraceLevel(this.logger.logLevel);

if (options.debug) {
this.razorTelemetryReporter.reportDebugLanguageServer();
Expand Down
2 changes: 0 additions & 2 deletions src/razor/src/razorLanguageServerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { LogLevel } from './logLevel';

export interface RazorLanguageServerOptions {
serverPath: string;
outputChannel?: vscode.OutputChannel;
debug?: boolean;
logLevel: LogLevel;
usingOmniSharp: boolean;
forceRuntimeCodeGeneration: boolean;
useRoslynTokenizer: boolean;
Expand Down
3 changes: 0 additions & 3 deletions src/razor/src/razorLanguageServerOptionsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import * as vscodeAdapter from './vscodeAdapter';
import * as vscode from 'vscode';
import { RazorLanguageServerOptions } from './razorLanguageServerOptions';
import { RazorLogger } from './razorLogger';
import { LogLevel } from './logLevel';
import { getCSharpDevKit } from '../../utils/getCSharpDevKit';

export function resolveRazorLanguageServerOptions(
vscodeApi: vscodeAdapter.api,
languageServerDir: string,
logLevel: LogLevel,
logger: RazorLogger
) {
const languageServerExecutablePath = findLanguageServerExecutable(languageServerDir);
Expand All @@ -31,7 +29,6 @@ export function resolveRazorLanguageServerOptions(
return {
serverPath: languageServerExecutablePath,
debug: debugLanguageServer,
logLevel: logLevel,
outputChannel: logger.outputChannel,
usingOmniSharp,
forceRuntimeCodeGeneration,
Expand Down
42 changes: 0 additions & 42 deletions src/razor/src/razorLanguageServerTraceResolver.ts

This file was deleted.

Loading

0 comments on commit bf8af14

Please sign in to comment.