Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
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
32 changes: 17 additions & 15 deletions src/Core/Loggers/QsharpLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,24 @@ public QSharpLogger(ILogger logger, int lineNrOffset = 0) :
this.Logs = new List<LSP.Diagnostic>();
}

public static LogLevel MapLevel(LSP.DiagnosticSeverity original)
{
switch (original)
// NB: We define both a method which takes a
// Nullable<DiagnosticSeverity> and a plain DiagnosticSeverity
// value directly, as different versions of the LSP client API
// vary in their handling of nullablity of diagnostic severity.
// This allows IQ# to build with both different versions.
// At some point, the non-nullable overload should be removed.
public static LogLevel MapLevel(LSP.DiagnosticSeverity? original) =>
original switch
{
case LSP.DiagnosticSeverity.Error:
return LogLevel.Error;
case LSP.DiagnosticSeverity.Warning:
return LogLevel.Warning;
case LSP.DiagnosticSeverity.Information:
return LogLevel.Information;
case LSP.DiagnosticSeverity.Hint:
return LogLevel.Debug;
default:
return LogLevel.Trace;
}
}
LSP.DiagnosticSeverity.Error => LogLevel.Error,
LSP.DiagnosticSeverity.Warning => LogLevel.Warning,
LSP.DiagnosticSeverity.Information => LogLevel.Information,
LSP.DiagnosticSeverity.Hint => LogLevel.Debug,
_ => LogLevel.Trace
};

public static LogLevel MapLevel(LSP.DiagnosticSeverity original) =>
MapLevel((LSP.DiagnosticSeverity?)original);

public bool HasErrors =>
Logs
Expand Down