diff --git a/src/ReportPortal.Extensions.SourceBack/SourceBackFormatter.cs b/src/ReportPortal.Extensions.SourceBack/SourceBackFormatter.cs index 702304a..9c3b2c3 100644 --- a/src/ReportPortal.Extensions.SourceBack/SourceBackFormatter.cs +++ b/src/ReportPortal.Extensions.SourceBack/SourceBackFormatter.cs @@ -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) @@ -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); @@ -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();