Skip to content

Commit 23db1d5

Browse files
committed
- PR feedback
1 parent 907c412 commit 23db1d5

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Logging.XUnit/XUnitLogger.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,18 @@ private static void GetScopeInformation(StringBuilder builder)
276276
}
277277

278278
var depth = 0;
279-
string DepthPadding(int depth) => new string(' ', depth * 2);
279+
static string DepthPadding(int depth) => new string(' ', depth * 2);
280280

281-
while (stack.Any())
281+
while (stack.Count > 0)
282282
{
283283
var elem = stack.Pop();
284284
foreach (var property in StringifyScope(elem))
285285
{
286-
builder.AppendLine($"{MessagePadding}{DepthPadding(depth)}=> {property}");
286+
builder.Append(MessagePadding)
287+
.Append(DepthPadding(depth))
288+
.Append("=> ")
289+
.Append(property)
290+
.AppendLine();
287291
}
288292

289293
depth++;
@@ -301,7 +305,7 @@ private static IEnumerable<string> StringifyScope(XUnitLogScope scope)
301305
{
302306
foreach (var pair in pairs)
303307
{
304-
yield return $"{pair.Key}: {pair.Value}";
308+
yield return pair.Key + ": " + pair.Value;
305309
}
306310
}
307311
else if (scope.State is IEnumerable<string> entries)

tests/Logging.XUnit.Tests/XUnitLoggerTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,9 @@ public static void XUnitLogger_Log_Logs_Message_If_Scopes_Included_And_There_Is_
501501

502502
string expected = string.Join(
503503
Environment.NewLine,
504-
new[] { "[2018-08-19 16:12:16Z] info: MyName[0]", " => ScopeKey: ScopeValue", " Message|False|False" });
504+
"[2018-08-19 16:12:16Z] info: MyName[0]",
505+
" => ScopeKey: ScopeValue",
506+
" Message|False|False");
505507

506508
// Act
507509
using (logger.BeginScope(new[]

0 commit comments

Comments
 (0)