Skip to content

Commit

Permalink
Not printing the log name for single logs in test outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Piedone committed Nov 10, 2024
1 parent 264d6ce commit 8393dd8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Lombiq.Tests.UI/Extensions/ApplicationLogEnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@ namespace Lombiq.Tests.UI.Extensions;

public static class ApplicationLogEnumerableExtensions
{
public static async Task<string> ToFormattedStringAsync(this IEnumerable<IApplicationLog> logs) =>
string.Join(
public static async Task<string> ToFormattedStringAsync(this IEnumerable<IApplicationLog> logs)
{
var logsArray = logs.ToArray();

if (logsArray.Length == 1)
{
return Environment.NewLine + await LogLinesToFormattedStringAsync(logsArray[0]);
}

return string.Join(
Environment.NewLine + Environment.NewLine,
await Task.WhenAll(
logs.Select(async log =>
logsArray.Select(async log =>
$"# Log name: {log.Name}" +
Environment.NewLine +
Environment.NewLine +
string.Join(Environment.NewLine, (await log.GetEntriesAsync()).Select(logEntry => logEntry.ToString())))));
await LogLinesToFormattedStringAsync(log))));
}

private static async Task<string> LogLinesToFormattedStringAsync(IApplicationLog log) =>
string.Join(Environment.NewLine, (await log.GetEntriesAsync()).Select(logEntry => logEntry.ToString()));
}

0 comments on commit 8393dd8

Please sign in to comment.