diff --git a/src/Core.UnitTests/Logging/LoggerBaseTests.cs b/src/Core.UnitTests/Logging/LoggerBaseTests.cs index 1ebea4c2b..31f8d59fc 100644 --- a/src/Core.UnitTests/Logging/LoggerBaseTests.cs +++ b/src/Core.UnitTests/Logging/LoggerBaseTests.cs @@ -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] @@ -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] @@ -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] @@ -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] @@ -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] @@ -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)] @@ -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] @@ -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"); } } diff --git a/src/Core/Logging/LoggerBase.cs b/src/Core/Logging/LoggerBase.cs index 035d26b55..c287b41d6 100644 --- a/src/Core/Logging/LoggerBase.cs +++ b/src/Core/Logging/LoggerBase.cs @@ -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)) diff --git a/src/Core/Logging/LoggerContextManager.cs b/src/Core/Logging/LoggerContextManager.cs index 10f060267..25ac91fa1 100644 --- a/src/Core/Logging/LoggerContextManager.cs +++ b/src/Core/Logging/LoggerContextManager.cs @@ -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 contexts; private readonly ImmutableList verboseContexts;