Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always log error responses with error level #1963

Merged
merged 4 commits into from
Sep 29, 2020
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
18 changes: 14 additions & 4 deletions src/OmniSharp.Stdio/Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ private async Task HandleRequest(string json, ILogger logger)
}
finally
{
if (logger.IsEnabled(LogLevel.Debug))
// response gets logged when Debug or more detailed log level is enabled
// or when we have unsuccessful response (exception)
if (logger.IsEnabled(LogLevel.Debug) || !response.Success)
{
LogResponse(response.ToString(), logger);
LogResponse(response.ToString(), logger, response.Success);
}

// actually write it
Expand All @@ -257,14 +259,22 @@ void LogRequest(string json, ILogger logger)
}
}

void LogResponse(string json, ILogger logger)
void LogResponse(string json, ILogger logger, bool isSuccess)
{
var builder = _cachedStringBuilder.Acquire();
try
{
builder.AppendLine("************ Response ************ ");
builder.Append(JToken.Parse(json).ToString(Formatting.Indented));
logger.LogDebug(builder.ToString());

if (isSuccess)
{
logger.LogDebug(builder.ToString());
}
else
{
logger.LogError(builder.ToString());
}
}
finally
{
Expand Down