Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static ImmutableArray<string> GetRestorePaths(RestoreParams request, Sol
.Distinct()
.ToImmutableArray();

context.TraceInformation($"Found {projects.Length} restorable projects from {solution.Projects.Count()} projects in solution");
context.TraceDebug($"Found {projects.Length} restorable projects from {solution.Projects.Count()} projects in solution");
return projects;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public LspServiceLogger(ILogger hostLogger)
/// <summary>
/// TODO - Switch this to call LogInformation once appropriate callers have been changed to LogDebug.
/// </summary>
public override void LogInformation(string message, params object[] @params) => _hostLogger.LogDebug(message, @params);
public override void LogInformation(string message, params object[] @params) => _hostLogger.LogInformation(message, @params);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were previously downgrading all info logs to debug in vscode because information logs were too verbose. That was because originally the lowest LSP logger level was info, and we ended up logging everything as info.

this fixes it by logging info as info, and adjusting the usages of info logging to a more appropriate level.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thank you for finally fixing this!


public override void LogWarning(string message, params object[] @params) => _hostLogger.LogWarning(message, @params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ protected IRequestExecutionQueue<TRequestContext> GetRequestExecutionQueue()

public virtual bool TryGetLanguageForRequest(string methodName, object? serializedRequest, [NotNullWhen(true)] out string? language)
{
Logger.LogInformation($"Using default language handler for {methodName}");
Logger.LogDebug($"Using default language handler for {methodName}");
language = LanguageServerConstants.DefaultLanguageName;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public async Task StartRequestAsync<TRequest, TResponse>(TRequest request, TRequ
{
// Record logs + metrics on cancellation.
_requestTelemetryScope?.RecordCancellation();
_logger.LogInformation($"Request was cancelled.");
_logger.LogDebug($"Request was cancelled.");

_completionSource.TrySetCanceled(ex.CancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ public static LSP.Range TextSpanToRange(TextSpan textSpan, SourceText text)

if (uri == null)
{
context?.TraceInformation($"Could not convert '{mappedSpan.FilePath}' to uri");
context?.TraceWarning($"Could not convert '{mappedSpan.FilePath}' to uri");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal sealed class CodeActionResolveHelper
data,
operations,
context.GetRequiredClientCapabilities().Workspace?.WorkspaceEdit?.ResourceOperations ?? [],
context.TraceInformation,
context.TraceDebug,
cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public CompletionResolveHandler(IGlobalOptionService globalOptions)
if (!completionListCache.TryGetCompletionListCacheEntry(completionItem, out var cacheEntry))
{
// Don't have a cache associated with this completion item, cannot resolve.
context.TraceInformation("No cache entry found for the provided completion item at resolve time.");
context.TraceWarning("No cache entry found for the provided completion item at resolve time.");
return Task.FromResult(completionItem);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override ValueTask<ImmutableArray<IDiagnosticSource>> GetOrderedDiagno
var textDocument = context.TextDocument;
if (textDocument is null)
{
context.TraceInformation("Ignoring diagnostics request because no text document was provided");
context.TraceDebug("Ignoring diagnostics request because no text document was provided");
return new([]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected virtual Task WaitForChangesAsync(string? category, RequestContext cont
// noise. It is not exposed to the user.
if (!this.GlobalOptions.GetOption(SolutionCrawlerRegistrationService.EnableSolutionCrawler))
{
context.TraceInformation($"{this.GetType()}. Skipping due to {nameof(SolutionCrawlerRegistrationService.EnableSolutionCrawler)}={false}");
context.TraceDebug($"{this.GetType()}. Skipping due to {nameof(SolutionCrawlerRegistrationService.EnableSolutionCrawler)}={false}");
}
else
{
Expand All @@ -116,15 +116,15 @@ protected virtual Task WaitForChangesAsync(string? category, RequestContext cont
var clientCapabilities = context.GetRequiredClientCapabilities();
var category = GetRequestDiagnosticCategory(diagnosticsParams);
var handlerName = $"{this.GetType().Name}(category: {category})";
context.TraceInformation($"{handlerName} started getting diagnostics");
context.TraceDebug($"{handlerName} started getting diagnostics");

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really related to this, but whenever I saw this in the logs it was very unclear what this was related to. Not sure if it should also be prefixed with handlerName or something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it already is prefixed by the method name
image


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

context.TraceInformation($"Processing {orderedSources.Length} documents");
context.TraceDebug($"Processing {orderedSources.Length} documents");

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

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

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

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

// Client is asking server about a document that no longer exists (i.e. was removed/deleted from
// the workspace). Report a (null-diagnostics, null-result-id) response to the client as that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected override async Task WaitForChangesAsync(string? category, RequestConte
}

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

bool HasChanged()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static bool ShouldSkipDocument(RequestContext context, TextDocument docum
// Each handler treats those as separate worlds that they are responsible for.
if (context.IsTracking(document.GetURI()))
{
context.TraceInformation($"Skipping tracked document: {document.GetURI()}");
context.TraceDebug($"Skipping tracked document: {document.GetURI()}");
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private sealed class DiagnosticsPullCache(IGlobalOptionService globalOptions, st
public override async Task<ImmutableArray<DiagnosticData>> ComputeDataAsync(DiagnosticsRequestState state, CancellationToken cancellationToken)
{
var diagnostics = await state.DiagnosticSource.GetDiagnosticsAsync(state.Context, cancellationToken).ConfigureAwait(false);
state.Context.TraceInformation($"Found {diagnostics.Length} diagnostics for {state.DiagnosticSource.ToDisplayString()}");
state.Context.TraceDebug($"Found {diagnostics.Length} diagnostics for {state.DiagnosticSource.ToDisplayString()}");
return diagnostics;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DidCloseHandler()
public async Task HandleNotificationAsync(LSP.DidCloseTextDocumentParams request, RequestContext context, CancellationToken cancellationToken)
{
// GetTextDocumentIdentifier returns null to avoid creating the solution, so the queue is not able to log the uri.
context.TraceInformation($"didClose for {request.TextDocument.DocumentUri}");
context.TraceDebug($"didClose for {request.TextDocument.DocumentUri}");

await context.StopTrackingAsync(request.TextDocument.DocumentUri, cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public DidOpenHandler()
public async Task HandleNotificationAsync(LSP.DidOpenTextDocumentParams request, RequestContext context, CancellationToken cancellationToken)
{
// GetTextDocumentIdentifier returns null to avoid creating the solution, so the queue is not able to log the uri.
context.TraceInformation($"didOpen for {request.TextDocument.DocumentUri}");
context.TraceDebug($"didOpen for {request.TextDocument.DocumentUri}");

// Add the document and ensure the text we have matches whats on the client
// TODO (https://github.com/dotnet/roslyn/issues/63583):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public XmlSnippetParser()
ParsedXmlSnippet? parsedSnippet = null;
try
{
logger.LogInformation($"Reading snippet for {matchingSnippetInfo.Title} with path {matchingSnippetInfo.Path}");
logger.LogDebug($"Reading snippet for {matchingSnippetInfo.Title} with path {matchingSnippetInfo.Path}");
parsedSnippet = GetAndParseSnippetFromFile(matchingSnippetInfo);
}
catch (Exception ex) when (FatalError.ReportAndCatch(ex, ErrorSeverity.General))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public MapCodeHandler()

if (textChanges is null)
{
context.TraceInformation($"mapCode sub-request for {textDocument.DocumentUri} failed: 'IMapCodeService.MapCodeAsync' returns null.");
context.TraceDebug($"mapCode sub-request for {textDocument.DocumentUri} failed: 'IMapCodeService.MapCodeAsync' returns null.");
return null;
}

Expand All @@ -127,7 +127,7 @@ public MapCodeHandler()
// Ignore anything not in target document, which current code mapper doesn't handle anyway
if (!location.DocumentUri.Equals(textDocumentIdentifier.DocumentUri))
{
context.TraceInformation($"A focus location in '{textDocumentIdentifier.DocumentUri}' is skipped, only locations in corresponding MapCodeMapping.TextDocument is currently considered.");
context.TraceDebug($"A focus location in '{textDocumentIdentifier.DocumentUri}' is skipped, only locations in corresponding MapCodeMapping.TextDocument is currently considered.");
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,17 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(VSInternalRelatedDocumen
public async Task<VSInternalRelatedDocumentReport[]?> HandleRequestAsync(
VSInternalRelatedDocumentParams requestParams, RequestContext context, CancellationToken cancellationToken)
{
context.TraceInformation($"{this.GetType()} started getting related documents");

var solution = context.Solution;
var document = context.Document;
Contract.ThrowIfNull(solution);
Contract.ThrowIfNull(document);

context.TraceInformation($"Processing: {document.FilePath}");
context.TraceDebug($"Processing: {document.FilePath}");

var relatedDocumentsService = document.GetLanguageService<IRelatedDocumentsService>();
if (relatedDocumentsService == null)
{
context.TraceInformation($"Ignoring document '{document.FilePath}' because it does not support related documents");
context.TraceDebug($"Ignoring document '{document.FilePath}' because it does not support related documents");
return [];
}

Expand Down Expand Up @@ -85,7 +83,6 @@ await relatedDocumentsService.GetRelatedDocumentIdsAsync(

// If we had a progress object, then we will have been reporting to that. Otherwise, take what we've been
// collecting and return that.
context.TraceInformation($"{this.GetType()} finished getting related documents");
return progress.GetFlattenedValues();
}
}
7 changes: 5 additions & 2 deletions src/LanguageServer/Protocol/Handler/RequestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@ public SourceText GetTrackedDocumentSourceText(DocumentUri documentUri)
// handler treats those as separate worlds that they are responsible for.
if (TextDocument is not TDocument document)
{
TraceInformation($"Ignoring diagnostics request because no {typeof(TDocument).Name} was provided");
TraceDebug($"Ignoring diagnostics request because no {typeof(TDocument).Name} was provided");
return null;
}

if (!IsTracking(document.GetURI()))
{
TraceWarning($"Ignoring diagnostics request for untracked document: {document.GetURI()}");
TraceDebug($"Ignoring diagnostics request for untracked document: {document.GetURI()}");
return null;
}

Expand All @@ -361,6 +361,9 @@ public void ClearSolutionContext()
_lspSolution.Value = default;
}

public void TraceDebug(string message)
=> _logger.LogDebug(message);

/// <summary>
/// Logs an informational message.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ protected AbstractSpellCheckHandler()
public async Task<TReport[]?> HandleRequestAsync(
TParams requestParams, RequestContext context, CancellationToken cancellationToken)
{
context.TraceInformation($"{this.GetType()} started getting spell checking spans");
context.TraceDebug($"{this.GetType()} started getting spell checking spans");

// The progress object we will stream reports to.
using var progress = BufferedProgress.Create(requestParams.PartialResultToken);

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

// First, let the client know if any workspace documents have gone away. That way it can remove those for
// the user from squiggles or error-list.
Expand All @@ -84,16 +84,16 @@ protected AbstractSpellCheckHandler()
// Next process each file in priority order. Determine if spans are changed or unchanged since the
// last time we notified the client. Report back either to the client so they can update accordingly.
var orderedDocuments = GetOrderedDocuments(context, cancellationToken);
context.TraceInformation($"Processing {orderedDocuments.Length} documents");
context.TraceDebug($"Processing {orderedDocuments.Length} documents");

foreach (var document in orderedDocuments)
{
context.TraceInformation($"Processing: {document.FilePath}");
context.TraceDebug($"Processing: {document.FilePath}");

var languageService = document.GetLanguageService<ISpellCheckSpanService>();
if (languageService == null)
{
context.TraceInformation($"Ignoring document '{document.FilePath}' because it does not support spell checking");
context.TraceDebug($"Ignoring document '{document.FilePath}' because it does not support spell checking");
continue;
}

Expand All @@ -107,7 +107,7 @@ protected AbstractSpellCheckHandler()
if (newResult != null)
{
var (newResultId, spans) = newResult.Value;
context.TraceInformation($"Spans were changed for document: {document.FilePath}");
context.TraceDebug($"Spans were changed for document: {document.FilePath}");
foreach (var report in ReportCurrentSpans(
document, spans, newResultId))
{
Expand All @@ -116,7 +116,7 @@ protected AbstractSpellCheckHandler()
}
else
{
context.TraceInformation($"Spans were unchanged for document: {document.FilePath}");
context.TraceDebug($"Spans were unchanged for document: {document.FilePath}");

// Nothing changed between the last request and this one. Report a (null-spans, same-result-id)
// response to the client as that means they should just preserve the current spans they have for
Expand All @@ -128,7 +128,7 @@ protected AbstractSpellCheckHandler()

// If we had a progress object, then we will have been reporting to that. Otherwise, take what we've been
// collecting and return that.
context.TraceInformation($"{this.GetType()} finished getting spans");
context.TraceDebug($"{this.GetType()} finished getting spans");
return progress.GetFlattenedValues();
}

Expand Down Expand Up @@ -212,7 +212,7 @@ private async Task HandleRemovedDocumentsAsync(
var document = await context.Solution.GetTextDocumentAsync(textDocument, cancellationToken).ConfigureAwait(false);
if (document == null)
{
context.TraceInformation($"Clearing spans for removed document: {textDocument.DocumentUri}");
context.TraceDebug($"Clearing spans for removed document: {textDocument.DocumentUri}");

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