Skip to content

Commit 7496b67

Browse files
authored
Fix information logs getting logged as debug in VSCode (#78522)
Updates LSP logging to log using debug more appropriately, and fixes LSP server logging to not downgrade information logs to debug.
2 parents 0899e12 + ef70b9e commit 7496b67

File tree

24 files changed

+47
-47
lines changed

24 files changed

+47
-47
lines changed

src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/Handler/Restore/RestoreHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private static ImmutableArray<string> GetRestorePaths(RestoreParams request, Sol
106106
.Distinct()
107107
.ToImmutableArray();
108108

109-
context.TraceInformation($"Found {projects.Length} restorable projects from {solution.Projects.Count()} projects in solution");
109+
context.TraceDebug($"Found {projects.Length} restorable projects from {solution.Projects.Count()} projects in solution");
110110
return projects;
111111
}
112112
}

src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/LspServiceLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public LspServiceLogger(ILogger hostLogger)
3535
/// <summary>
3636
/// TODO - Switch this to call LogInformation once appropriate callers have been changed to LogDebug.
3737
/// </summary>
38-
public override void LogInformation(string message, params object[] @params) => _hostLogger.LogDebug(message, @params);
38+
public override void LogInformation(string message, params object[] @params) => _hostLogger.LogInformation(message, @params);
3939

4040
public override void LogWarning(string message, params object[] @params) => _hostLogger.LogWarning(message, @params);
4141
}

src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ protected IRequestExecutionQueue<TRequestContext> GetRequestExecutionQueue()
181181

182182
public virtual bool TryGetLanguageForRequest(string methodName, object? serializedRequest, [NotNullWhen(true)] out string? language)
183183
{
184-
Logger.LogInformation($"Using default language handler for {methodName}");
184+
Logger.LogDebug($"Using default language handler for {methodName}");
185185
language = LanguageServerConstants.DefaultLanguageName;
186186
return true;
187187
}

src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public async Task StartRequestAsync<TRequest, TResponse>(TRequest request, TRequ
223223
{
224224
// Record logs + metrics on cancellation.
225225
_requestTelemetryScope?.RecordCancellation();
226-
_logger.LogInformation($"Request was cancelled.");
226+
_logger.LogDebug($"Request was cancelled.");
227227

228228
_completionSource.TrySetCanceled(ex.CancellationToken);
229229
}

src/LanguageServer/Protocol/Extensions/ProtocolConversions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ public static LSP.Range TextSpanToRange(TextSpan textSpan, SourceText text)
492492

493493
if (uri == null)
494494
{
495-
context?.TraceInformation($"Could not convert '{mappedSpan.FilePath}' to uri");
495+
context?.TraceWarning($"Could not convert '{mappedSpan.FilePath}' to uri");
496496
return null;
497497
}
498498

src/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal sealed class CodeActionResolveHelper
3030
data,
3131
operations,
3232
context.GetRequiredClientCapabilities().Workspace?.WorkspaceEdit?.ResourceOperations ?? [],
33-
context.TraceInformation,
33+
context.TraceDebug,
3434
cancellationToken);
3535
}
3636

src/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public CompletionResolveHandler(IGlobalOptionService globalOptions)
5151
if (!completionListCache.TryGetCompletionListCacheEntry(completionItem, out var cacheEntry))
5252
{
5353
// Don't have a cache associated with this completion item, cannot resolve.
54-
context.TraceInformation("No cache entry found for the provided completion item at resolve time.");
54+
context.TraceWarning("No cache entry found for the provided completion item at resolve time.");
5555
return Task.FromResult(completionItem);
5656
}
5757

src/LanguageServer/Protocol/Handler/Diagnostics/AbstractDocumentPullDiagnosticHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected override ValueTask<ImmutableArray<IDiagnosticSource>> GetOrderedDiagno
3737
var textDocument = context.TextDocument;
3838
if (textDocument is null)
3939
{
40-
context.TraceInformation("Ignoring diagnostics request because no text document was provided");
40+
context.TraceDebug("Ignoring diagnostics request because no text document was provided");
4141
return new([]);
4242
}
4343

src/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected virtual Task WaitForChangesAsync(string? category, RequestContext cont
107107
// noise. It is not exposed to the user.
108108
if (!this.GlobalOptions.GetOption(SolutionCrawlerRegistrationService.EnableSolutionCrawler))
109109
{
110-
context.TraceInformation($"{this.GetType()}. Skipping due to {nameof(SolutionCrawlerRegistrationService.EnableSolutionCrawler)}={false}");
110+
context.TraceDebug($"{this.GetType()}. Skipping due to {nameof(SolutionCrawlerRegistrationService.EnableSolutionCrawler)}={false}");
111111
}
112112
else
113113
{
@@ -116,15 +116,15 @@ protected virtual Task WaitForChangesAsync(string? category, RequestContext cont
116116
var clientCapabilities = context.GetRequiredClientCapabilities();
117117
var category = GetRequestDiagnosticCategory(diagnosticsParams);
118118
var handlerName = $"{this.GetType().Name}(category: {category})";
119-
context.TraceInformation($"{handlerName} started getting diagnostics");
119+
context.TraceDebug($"{handlerName} started getting diagnostics");
120120

121121
var versionedCache = _categoryToVersionedCache.GetOrAdd(
122122
handlerName, static (handlerName, globalOptions) => new(globalOptions, handlerName), GlobalOptions);
123123

124124
// Get the set of results the request said were previously reported. We can use this to determine both
125125
// what to skip, and what files we have to tell the client have been removed.
126126
var previousResults = GetPreviousResults(diagnosticsParams) ?? [];
127-
context.TraceInformation($"previousResults.Length={previousResults.Length}");
127+
context.TraceDebug($"previousResults.Length={previousResults.Length}");
128128

129129
// Create a mapping from documents to the previous results the client says it has for them. That way as we
130130
// process documents we know if we should tell the client it should stay the same, or we can tell it what
@@ -142,7 +142,7 @@ protected virtual Task WaitForChangesAsync(string? category, RequestContext cont
142142
var orderedSources = await GetOrderedDiagnosticSourcesAsync(
143143
diagnosticsParams, category, context, cancellationToken).ConfigureAwait(false);
144144

145-
context.TraceInformation($"Processing {orderedSources.Length} documents");
145+
context.TraceDebug($"Processing {orderedSources.Length} documents");
146146

147147
// Keep track of what diagnostic sources we see this time around. For any we do not see this time
148148
// around, we'll notify the client that the diagnostics for it have been removed.
@@ -169,7 +169,7 @@ protected virtual Task WaitForChangesAsync(string? category, RequestContext cont
169169
}
170170
else
171171
{
172-
context.TraceInformation($"Diagnostics were unchanged for {diagnosticSource.ToDisplayString()}");
172+
context.TraceDebug($"Diagnostics were unchanged for {diagnosticSource.ToDisplayString()}");
173173

174174
// Nothing changed between the last request and this one. Report a (null-diagnostics,
175175
// same-result-id) response to the client as that means they should just preserve the current
@@ -212,7 +212,7 @@ protected virtual Task WaitForChangesAsync(string? category, RequestContext cont
212212

213213
// If we had a progress object, then we will have been reporting to that. Otherwise, take what we've been
214214
// collecting and return that.
215-
context.TraceInformation($"{this.GetType()} finished getting diagnostics");
215+
context.TraceDebug($"{this.GetType()} finished getting diagnostics");
216216
}
217217

218218
return CreateReturn(progress);
@@ -297,7 +297,7 @@ private void HandleRemovedDocuments(RequestContext context, HashSet<PreviousPull
297297
{
298298
foreach (var removedResult in removedPreviousResults)
299299
{
300-
context.TraceInformation($"Clearing diagnostics for removed document: {removedResult.TextDocument.DocumentUri}");
300+
context.TraceDebug($"Clearing diagnostics for removed document: {removedResult.TextDocument.DocumentUri}");
301301

302302
// Client is asking server about a document that no longer exists (i.e. was removed/deleted from
303303
// the workspace). Report a (null-diagnostics, null-result-id) response to the client as that

src/LanguageServer/Protocol/Handler/Diagnostics/AbstractWorkspacePullDiagnosticsHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected override async Task WaitForChangesAsync(string? category, RequestConte
114114
}
115115

116116
// We've hit a change, so we close the current request to allow the client to open a new one.
117-
context.TraceInformation($"Closing workspace/diagnostics request for {category}");
117+
context.TraceDebug($"Closing workspace/diagnostics request for {category}");
118118
return;
119119

120120
bool HasChanged()

0 commit comments

Comments
 (0)