Skip to content

Commit

Permalink
Modify log request text only if handled source info
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko committed Jan 22, 2022
1 parent 55e22ad commit a34f31e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public void FormatLog(CreateLogItemRequest logRequest)
{
_traceLogger.Verbose("Received a log request to format.");

var handled = false;

var fullMessageBuilder = Config.GetValue("Extensions:SourceBack:WithMarkdownPrefix", false) ? new StringBuilder("!!!MARKDOWN_MODE!!!") : new StringBuilder();

if (logRequest.Level == LogLevel.Error || logRequest.Level == LogLevel.Fatal)
Expand Down Expand Up @@ -145,6 +147,8 @@ public void FormatLog(CreateLogItemRequest logRequest)
sectionBuilder.AppendLine($"```{Environment.NewLine}SourceBack error: {exp}{Environment.NewLine}```");
}

handled = true;

if (!string.IsNullOrEmpty(sectionBuilder.ToString()))
{
var sourceFileName = Path.GetFileName(sourcePath);
Expand Down Expand Up @@ -173,7 +177,10 @@ public void FormatLog(CreateLogItemRequest logRequest)
}
}

logRequest.Text = fullMessageBuilder.ToString();
if (handled)
{
logRequest.Text = fullMessageBuilder.ToString();
}
}

private static readonly object _pdbsLock = new object();
Expand Down

0 comments on commit a34f31e

Please sign in to comment.