From a34f31ef4a112eae386ee4ea20980f21a8f3b098 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko Date: Sat, 22 Jan 2022 18:18:29 +0300 Subject: [PATCH] Modify log request text only if handled source info --- .../SourceBackFormatter.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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();