Skip to content

Commit

Permalink
change format
Browse files Browse the repository at this point in the history
  • Loading branch information
georgii-borovinskikh-sonarsource committed Dec 23, 2024
1 parent fbb97f3 commit ba2069e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/Core.UnitTests/Logging/LoggerBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void LogVerbose_ThreadIdLoggingEnabled_AddsThreadIdProperty()

testSubject.LogVerbose("msg {0}", "sent");

writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId, 3}] [DEBUG] msg sent");
writer.Received().WriteLine($"[DEBUG] [ThreadId {Thread.CurrentThread.ManagedThreadId}] msg sent");
}

[TestMethod]
Expand All @@ -134,7 +134,7 @@ public void LogVerbose_Context_AddsContextProperty()

testSubject.LogVerbose("msg {0}", "sent");

writer.Received().WriteLine("[context] [DEBUG] msg sent");
writer.Received().WriteLine("[DEBUG] [context] msg sent");
}

[TestMethod]
Expand All @@ -145,7 +145,7 @@ public void LogVerbose_VerboseContext_AddsVerboseContextProperty()

testSubject.LogVerbose("msg {0}", "sent");

writer.Received().WriteLine("[verbose context] [DEBUG] msg sent");
writer.Received().WriteLine("[DEBUG] [verbose context] msg sent");
}

[TestMethod]
Expand All @@ -158,7 +158,7 @@ public void LogVerbose_AllContextsEnabled_AddsInCorrectOrder()

testSubject.LogVerbose("msg {0}", "sent");

writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId, 3}] [context] [verbose context] [DEBUG] msg sent");
writer.Received().WriteLine($"[DEBUG] [ThreadId {Thread.CurrentThread.ManagedThreadId}] [context] [verbose context] msg sent");
}

[TestMethod]
Expand Down Expand Up @@ -208,7 +208,7 @@ public void WriteLine_ThreadIdLoggingEnabled_AddsThreadIdProperty()

testSubject.WriteLine("msg sent");

writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId, 3}] msg sent");
writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId}] msg sent");
}

[TestMethod]
Expand All @@ -218,7 +218,7 @@ public void WriteLineFormatted_ThreadIdLoggingEnabled_AddsThreadIdProperty()

testSubject.WriteLine("msg {0}", "sent");

writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId, 3}] msg sent");
writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId}] msg sent");
}

[DataRow(true)]
Expand Down Expand Up @@ -301,7 +301,7 @@ public void WriteLine_AllContextsEnabled_AddsInCorrectOrder()

testSubject.WriteLine("msg sent");

writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId, 3}] [context] [verbose context] msg sent");
writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId}] [context] [verbose context] msg sent");
}

[TestMethod]
Expand All @@ -314,6 +314,6 @@ public void WriteLineFormatted_AllContextsEnabled_AddsInCorrectOrder()

testSubject.WriteLine("msg {0}", "sent");

writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId, 3}] [context] [verbose context] msg sent");
writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId}] [context] [verbose context] msg sent");
}
}
4 changes: 2 additions & 2 deletions src/Core/Logging/LoggerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ private StringBuilder CreateStandardLogPrefix() =>
AddStandardProperties(new StringBuilder());

private StringBuilder CreateDebugLogPrefix() =>
AppendProperty(AddStandardProperties(new StringBuilder()), "DEBUG");
AddStandardProperties(AppendProperty(new StringBuilder(), "DEBUG"));

private StringBuilder AddStandardProperties(StringBuilder builder)
{
if (settingsProvider.IsThreadIdEnabled)
{
AppendPropertyFormat(builder, "ThreadId {0, 3}", Thread.CurrentThread.ManagedThreadId);
AppendPropertyFormat(builder, "ThreadId {0}", Thread.CurrentThread.ManagedThreadId);
}

if (!string.IsNullOrEmpty(contextManager.FormatedContext))
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Logging/LoggerContextManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace SonarLint.VisualStudio.Core.Logging;

[Export(typeof(ILoggerContextManager))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class LoggerContextManager : ILoggerContextManager
internal class LoggerContextManager : ILoggerContextManager
{
private readonly ImmutableList<string> contexts;
private readonly ImmutableList<string> verboseContexts;
Expand Down

0 comments on commit ba2069e

Please sign in to comment.