-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow logging level to be changed in rzls (#11228)
VS Code has a specific LogOutputChannel which allows the user to easily change the logging level on an output window. To support that rzls also needs to allow dynamic logging level changes. This adds an endpoint and a level provider that changes the logging level based on an lsp message coming in.
- Loading branch information
Showing
9 changed files
with
75 additions
and
19 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/Logging/LogLevelProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System.Threading; | ||
using Microsoft.CodeAnalysis.Razor.Logging; | ||
|
||
namespace Microsoft.AspNetCore.Razor.LanguageServer.Hosting.Logging; | ||
|
||
internal class LogLevelProvider(LogLevel logLevel) | ||
{ | ||
public LogLevel Current { get; set; } = logLevel; | ||
} |
13 changes: 13 additions & 0 deletions
13
...rc/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/Logging/RazorUpdateLogLevelParams.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System.Text.Json.Serialization; | ||
using Microsoft.CodeAnalysis.Razor.Logging; | ||
|
||
namespace Microsoft.AspNetCore.Razor.LanguageServer.Hosting.Logging; | ||
|
||
/// <summary> | ||
/// Request parameters for updating the log level in the server dynamically. | ||
/// </summary> | ||
/// <param name="LogLevel">the int value of the <see cref="LogLevel"/> enum</param> | ||
internal record class UpdateLogLevelParams([property: JsonPropertyName("logLevel")] int LogLevel); |
24 changes: 24 additions & 0 deletions
24
...r/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/Logging/UpdateLogLevelEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts; | ||
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting.Logging; | ||
using Microsoft.CodeAnalysis.Razor.Logging; | ||
using Microsoft.CodeAnalysis.Razor.Protocol; | ||
|
||
namespace Microsoft.AspNetCore.Razor.LanguageServer.Hosting.Logging; | ||
|
||
[RazorLanguageServerEndpoint(CustomMessageNames.RazorUpdateLogLevelName)] | ||
internal class UpdateLogLevelEndpoint(LogLevelProvider logLevelProvider) : IRazorNotificationHandler<UpdateLogLevelParams> | ||
{ | ||
public bool MutatesSolutionState => false; | ||
|
||
public Task HandleNotificationAsync(UpdateLogLevelParams request, RazorRequestContext requestContext, CancellationToken cancellationToken) | ||
{ | ||
logLevelProvider.Current = (LogLevel)request.LogLevel; | ||
return Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters