From 62dc2fafa728ebfd1f68ee5d73e271b77a9352d7 Mon Sep 17 00:00:00 2001 From: Georgii Borovinskikh Date: Mon, 6 Jan 2025 13:28:33 +0100 Subject: [PATCH] Add message-level logging context --- src/Core.UnitTests/Logging/LoggerBaseTests.cs | 36 ++++----- .../Logging/LoggerContextManagerTests.cs | 80 +++++++++++++++---- .../Logging/LoggerFactoryTests.cs | 2 +- src/Core/Logging/ILogger.cs | 36 +++++---- src/Core/Logging/ILoggerContextManager.cs | 4 +- src/Core/Logging/LoggerBase.cs | 31 ++++--- src/Core/Logging/LoggerContextManager.cs | 29 ++++++- .../Framework/TestLogger.cs | 4 + 8 files changed, 154 insertions(+), 68 deletions(-) diff --git a/src/Core.UnitTests/Logging/LoggerBaseTests.cs b/src/Core.UnitTests/Logging/LoggerBaseTests.cs index 31f8d59fc..b34c79f0a 100644 --- a/src/Core.UnitTests/Logging/LoggerBaseTests.cs +++ b/src/Core.UnitTests/Logging/LoggerBaseTests.cs @@ -50,8 +50,8 @@ public void ForContext_CreatesNewLoggerWithUpdatedContextManager() contextManager.Received(1).CreateAugmentedContext(Arg.Is>(x => x.SequenceEqual(new[] { "ctx" }))); newLogger.Should().NotBeSameAs(testSubject); newLogger.WriteLine("msg"); - _ = contextManager.DidNotReceive().FormatedContext; - _ = newContextManager.Received().FormatedContext; + contextManager.DidNotReceiveWithAnyArgs().GetFormattedContextOrNull(default); + newContextManager.ReceivedWithAnyArgs().GetFormattedContextOrNull(default); writer.Received().WriteLine(Arg.Any()); _ = settingsProvider.Received().IsVerboseEnabled; } @@ -78,8 +78,8 @@ public void ForVerboseContext_CreatesNewLoggerWithUpdatedContextManager() contextManager.Received(1).CreateAugmentedVerboseContext(Arg.Is>(x => x.SequenceEqual(new[] { "ctx" }))); newLogger.Should().NotBeSameAs(testSubject); newLogger.WriteLine("msg"); - _ = contextManager.DidNotReceive().FormatedContext; - _ = newContextManager.Received().FormatedContext; + contextManager.DidNotReceiveWithAnyArgs().GetFormattedContextOrNull(default); + newContextManager.ReceivedWithAnyArgs().GetFormattedContextOrNull(default); writer.Received().WriteLine(Arg.Any()); _ = settingsProvider.Received().IsVerboseEnabled; } @@ -130,7 +130,7 @@ public void LogVerbose_ThreadIdLoggingEnabled_AddsThreadIdProperty() public void LogVerbose_Context_AddsContextProperty() { settingsProvider.IsVerboseEnabled.Returns(true); - contextManager.FormatedContext.Returns("context"); + contextManager.GetFormattedContextOrNull(default).Returns("context"); testSubject.LogVerbose("msg {0}", "sent"); @@ -141,7 +141,7 @@ public void LogVerbose_Context_AddsContextProperty() public void LogVerbose_VerboseContext_AddsVerboseContextProperty() { settingsProvider.IsVerboseEnabled.Returns(true); - contextManager.FormatedVerboseContext.Returns("verbose context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); testSubject.LogVerbose("msg {0}", "sent"); @@ -153,8 +153,8 @@ public void LogVerbose_AllContextsEnabled_AddsInCorrectOrder() { settingsProvider.IsThreadIdEnabled.Returns(true); settingsProvider.IsVerboseEnabled.Returns(true); - contextManager.FormatedContext.Returns("context"); - contextManager.FormatedVerboseContext.Returns("verbose context"); + contextManager.GetFormattedContextOrNull(default).Returns("context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); testSubject.LogVerbose("msg {0}", "sent"); @@ -227,7 +227,7 @@ public void WriteLineFormatted_ThreadIdLoggingEnabled_AddsThreadIdProperty() public void WriteLine_Context_AddsContextProperty(bool isVerboseEnabled) { settingsProvider.IsVerboseEnabled.Returns(isVerboseEnabled); - contextManager.FormatedContext.Returns("context"); + contextManager.GetFormattedContextOrNull(default).Returns("context"); testSubject.WriteLine("msg sent"); @@ -240,7 +240,7 @@ public void WriteLine_Context_AddsContextProperty(bool isVerboseEnabled) public void WriteLineFormatted_Context_AddsContextProperty(bool isVerboseEnabled) { settingsProvider.IsVerboseEnabled.Returns(isVerboseEnabled); - contextManager.FormatedContext.Returns("context"); + contextManager.GetFormattedContextOrNull(default).Returns("context"); testSubject.WriteLine("msg {0}", "sent"); @@ -251,7 +251,7 @@ public void WriteLineFormatted_Context_AddsContextProperty(bool isVerboseEnabled public void WriteLine_VerboseContext_VerboseLoggingDisabled_DoesNotAddVerboseContextProperty() { settingsProvider.IsVerboseEnabled.Returns(false); - contextManager.FormatedVerboseContext.Returns("verbose context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); testSubject.WriteLine("msg sent"); @@ -262,7 +262,7 @@ public void WriteLine_VerboseContext_VerboseLoggingDisabled_DoesNotAddVerboseCon public void WriteLineFormatted_VerboseContext_VerboseLoggingDisabled_DoesNotAddVerboseContextProperty() { settingsProvider.IsVerboseEnabled.Returns(false); - contextManager.FormatedVerboseContext.Returns("verbose context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); testSubject.WriteLine("msg {0}", "sent"); @@ -273,7 +273,7 @@ public void WriteLineFormatted_VerboseContext_VerboseLoggingDisabled_DoesNotAddV public void WriteLine_VerboseContext_VerboseLoggingEnabled_AddsVerboseContextProperty() { settingsProvider.IsVerboseEnabled.Returns(true); - contextManager.FormatedVerboseContext.Returns("verbose context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); testSubject.WriteLine("msg sent"); @@ -284,7 +284,7 @@ public void WriteLine_VerboseContext_VerboseLoggingEnabled_AddsVerboseContextPro public void WriteLineFormatted_VerboseContext_VerboseLoggingEnabled_AddsVerboseContextProperty() { settingsProvider.IsVerboseEnabled.Returns(true); - contextManager.FormatedVerboseContext.Returns("verbose context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); testSubject.WriteLine("msg {0}", "sent"); @@ -296,8 +296,8 @@ public void WriteLine_AllContextsEnabled_AddsInCorrectOrder() { settingsProvider.IsThreadIdEnabled.Returns(true); settingsProvider.IsVerboseEnabled.Returns(true); - contextManager.FormatedContext.Returns("context"); - contextManager.FormatedVerboseContext.Returns("verbose context"); + contextManager.GetFormattedContextOrNull(default).Returns("context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); testSubject.WriteLine("msg sent"); @@ -309,8 +309,8 @@ public void WriteLineFormatted_AllContextsEnabled_AddsInCorrectOrder() { settingsProvider.IsThreadIdEnabled.Returns(true); settingsProvider.IsVerboseEnabled.Returns(true); - contextManager.FormatedContext.Returns("context"); - contextManager.FormatedVerboseContext.Returns("verbose context"); + contextManager.GetFormattedContextOrNull(default).Returns("context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); testSubject.WriteLine("msg {0}", "sent"); diff --git a/src/Core.UnitTests/Logging/LoggerContextManagerTests.cs b/src/Core.UnitTests/Logging/LoggerContextManagerTests.cs index f92065c74..0a88ff492 100644 --- a/src/Core.UnitTests/Logging/LoggerContextManagerTests.cs +++ b/src/Core.UnitTests/Logging/LoggerContextManagerTests.cs @@ -39,8 +39,8 @@ public void EmptyContext() { var testSubject = new LoggerContextManager(); - testSubject.FormatedContext.Should().BeNull(); - testSubject.FormatedVerboseContext.Should().BeNull(); + testSubject.GetFormattedContextOrNull(default).Should().BeNull(); + testSubject.GetFormattedVerboseContextOrNull(default).Should().BeNull(); } [TestMethod] @@ -51,28 +51,28 @@ public void Augmented_Immutable() var verboseContextualized = testSubject.CreateAugmentedVerboseContext(["b"]); var doubleContextualized = testSubject.CreateAugmentedContext(["c"]).CreateAugmentedVerboseContext(["d"]); - testSubject.FormatedContext.Should().BeNull(); - testSubject.FormatedVerboseContext.Should().BeNull(); - contextualized.FormatedContext.Should().Be("a"); - contextualized.FormatedVerboseContext.Should().BeNull(); - verboseContextualized.FormatedContext.Should().BeNull(); - verboseContextualized.FormatedVerboseContext.Should().Be("b"); - doubleContextualized.FormatedContext.Should().Be("c"); - doubleContextualized.FormatedVerboseContext.Should().Be("d"); + testSubject.GetFormattedContextOrNull(default).Should().BeNull(); + testSubject.GetFormattedVerboseContextOrNull(default).Should().BeNull(); + contextualized.GetFormattedContextOrNull(default).Should().Be("a"); + contextualized.GetFormattedVerboseContextOrNull(default).Should().BeNull(); + verboseContextualized.GetFormattedContextOrNull(default).Should().BeNull(); + verboseContextualized.GetFormattedVerboseContextOrNull(default).Should().Be("b"); + doubleContextualized.GetFormattedContextOrNull(default).Should().Be("c"); + doubleContextualized.GetFormattedVerboseContextOrNull(default).Should().Be("d"); } [TestMethod] public void Augmented_MultipleAtOnce_Combines() => new LoggerContextManager() .CreateAugmentedContext(["a", "b"]) - .FormatedContext.Should().Be("a > b"); + .GetFormattedContextOrNull(default).Should().Be("a > b"); [TestMethod] public void Augmented_MultipleInSequence_Combines() => new LoggerContextManager() .CreateAugmentedContext(["a"]) .CreateAugmentedContext(["b"]) - .FormatedContext.Should().Be("a > b"); + .GetFormattedContextOrNull(default).Should().Be("a > b"); [TestMethod] public void Augmented_AtOnceAndInSequence_CombinesInCorrectOrder() => @@ -80,20 +80,20 @@ public void Augmented_AtOnceAndInSequence_CombinesInCorrectOrder() => .CreateAugmentedContext(["a"]) .CreateAugmentedContext(["b", "c"]) .CreateAugmentedContext(["d"]) - .FormatedContext.Should().Be("a > b > c > d"); + .GetFormattedContextOrNull(default).Should().Be("a > b > c > d"); [TestMethod] public void AugmentedVerbose_MultipleAtOnce_Combines() => new LoggerContextManager() .CreateAugmentedVerboseContext(["a", "b"]) - .FormatedVerboseContext.Should().Be("a > b"); + .GetFormattedVerboseContextOrNull(default).Should().Be("a > b"); [TestMethod] public void AugmentedVerbose_MultipleInSequence_Combines() => new LoggerContextManager() .CreateAugmentedVerboseContext(["a"]) .CreateAugmentedVerboseContext(["b"]) - .FormatedVerboseContext.Should().Be("a > b"); + .GetFormattedVerboseContextOrNull(default).Should().Be("a > b"); [TestMethod] public void AugmentedVerbose_AtOnceAndInSequence_CombinesInCorrectOrder() => @@ -101,5 +101,53 @@ public void AugmentedVerbose_AtOnceAndInSequence_CombinesInCorrectOrder() => .CreateAugmentedVerboseContext(["a"]) .CreateAugmentedVerboseContext(["b", "c"]) .CreateAugmentedVerboseContext(["d"]) - .FormatedVerboseContext.Should().Be("a > b > c > d"); + .GetFormattedVerboseContextOrNull(default).Should().Be("a > b > c > d"); + + [TestMethod] + public void Get_NoContext_ReturnsNull() => + new LoggerContextManager().GetFormattedContextOrNull(new MessageLevelContext{Context = null, VerboseContext = ["c", "d"]}).Should().BeNull(); + + [TestMethod] + public void Get_NoBaseContext_ReturnsMessageLevelContextOnly() => + new LoggerContextManager().GetFormattedContextOrNull(new MessageLevelContext{Context = ["a", "b"], VerboseContext = ["c", "d"]}).Should().Be("a > b"); + + [TestMethod] + public void Get_MessageLevelContextNotCached() + { + var testSubject = new LoggerContextManager(); + testSubject.GetFormattedContextOrNull(new MessageLevelContext{Context = ["a", "b"], VerboseContext = ["c", "d"]}).Should().Be("a > b"); + testSubject.GetFormattedContextOrNull(new MessageLevelContext{Context = ["a2", "b2"], VerboseContext = ["c", "d"]}).Should().Be("a2 > b2"); + } + + [TestMethod] + public void Get_NoMessageLevelContext_ReturnsBaseContextOnly() => + new LoggerContextManager().CreateAugmentedContext(["x", "y"]).GetFormattedContextOrNull(new MessageLevelContext{Context = null, VerboseContext = ["c", "d"]}).Should().Be("x > y"); + + [TestMethod] + public void Get_BothContexts_CombinesInOrder() => + new LoggerContextManager().CreateAugmentedContext(["x", "y"]).GetFormattedContextOrNull(new MessageLevelContext{Context = ["a", "b"], VerboseContext = ["c", "d"]}).Should().Be("x > y > a > b"); + + [TestMethod] + public void GetVerbose_NoContext_ReturnsNull() => + new LoggerContextManager().GetFormattedVerboseContextOrNull(new MessageLevelContext{Context = ["a", "b"], VerboseContext = null}).Should().BeNull(); + + [TestMethod] + public void GetVerbose_NoBaseContext_ReturnsMessageLevelContextOnly() => + new LoggerContextManager().GetFormattedVerboseContextOrNull(new MessageLevelContext{Context = ["a", "b"], VerboseContext = ["c", "d"]}).Should().Be("c > d"); + + [TestMethod] + public void GetVerbose_MessageLevelContextNotCached() + { + var testSubject = new LoggerContextManager(); + testSubject.GetFormattedVerboseContextOrNull(new MessageLevelContext { Context = ["a", "b"], VerboseContext = ["c", "d"] }).Should().Be("c > d"); + testSubject.GetFormattedVerboseContextOrNull(new MessageLevelContext { Context = ["a", "b"], VerboseContext = ["c2", "d2"] }).Should().Be("c2 > d2"); + } + + [TestMethod] + public void GetVerbose_NoMessageLevelContext_ReturnsBaseContextOnly() => + new LoggerContextManager().CreateAugmentedVerboseContext(["v", "w"]).GetFormattedVerboseContextOrNull(new MessageLevelContext{Context = ["a", "b"], VerboseContext = null}).Should().Be("v > w"); + + [TestMethod] + public void GetVerbose_BothContexts_CombinesInOrder() => + new LoggerContextManager().CreateAugmentedVerboseContext(["v", "w"]).GetFormattedVerboseContextOrNull(new MessageLevelContext{Context = ["a", "b"], VerboseContext = ["c", "d"]}).Should().Be("v > w > c > d"); } diff --git a/src/Core.UnitTests/Logging/LoggerFactoryTests.cs b/src/Core.UnitTests/Logging/LoggerFactoryTests.cs index 76a43c5e6..a150547d7 100644 --- a/src/Core.UnitTests/Logging/LoggerFactoryTests.cs +++ b/src/Core.UnitTests/Logging/LoggerFactoryTests.cs @@ -56,7 +56,7 @@ public void Create_ReturnsLoggerConfiguredWithCorrectDependencies() logger.Should().NotBeNull(); logger.WriteLine("msg"); - _ = logContextManager.Received().FormatedContext; + logContextManager.Received().GetFormattedContextOrNull(default); _ = logVerbosityIndicator.Received().IsVerboseEnabled; logWriter.Received().WriteLine(Arg.Is(x => x.Contains("msg"))); } diff --git a/src/Core/Logging/ILogger.cs b/src/Core/Logging/ILogger.cs index e59495abd..16d2231f0 100644 --- a/src/Core/Logging/ILogger.cs +++ b/src/Core/Logging/ILogger.cs @@ -18,26 +18,30 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -using System.ComponentModel.Composition; +namespace SonarLint.VisualStudio.Core; -namespace SonarLint.VisualStudio.Core +public interface ILogger { - public interface ILogger - { - /// - /// Logs a message and appends a new line. - /// - void WriteLine(string message); + /// + /// Logs a message and appends a new line. + /// + void WriteLine(string message); + void WriteLine(string messageFormat, params object[] args); + void WriteLine(MessageLevelContext context, string messageFormat, params object[] args); - void WriteLine(string messageFormat, params object[] args); + /// + /// Logs a message and appends a new line if logging is set to verbose. Otherwise does nothing. + /// + void LogVerbose(string messageFormat, params object[] args); + void LogVerbose(MessageLevelContext context, string messageFormat, params object[] args); - /// - /// Logs a message and appends a new line if logging is set to verbose. Otherwise does nothing. - /// - void LogVerbose(string messageFormat, params object[] args); + ILogger ForContext(params string[] context); - ILogger ForContext(params string[] context); + ILogger ForVerboseContext(params string[] context); +} - ILogger ForVerboseContext(params string[] context); - } +public readonly struct MessageLevelContext +{ + public IReadOnlyCollection Context { get; init; } + public IReadOnlyCollection VerboseContext { get; init; } } diff --git a/src/Core/Logging/ILoggerContextManager.cs b/src/Core/Logging/ILoggerContextManager.cs index 8b1f06a90..053171b0c 100644 --- a/src/Core/Logging/ILoggerContextManager.cs +++ b/src/Core/Logging/ILoggerContextManager.cs @@ -22,8 +22,8 @@ namespace SonarLint.VisualStudio.Core.Logging; public interface ILoggerContextManager { - public string FormatedContext { get; } - public string FormatedVerboseContext { get; } + public string GetFormattedContextOrNull(MessageLevelContext messageLevelContext); + public string GetFormattedVerboseContextOrNull(MessageLevelContext messageLevelContext); ILoggerContextManager CreateAugmentedContext(IEnumerable additionalContexts); diff --git a/src/Core/Logging/LoggerBase.cs b/src/Core/Logging/LoggerBase.cs index c287b41d6..350799de4 100644 --- a/src/Core/Logging/LoggerBase.cs +++ b/src/Core/Logging/LoggerBase.cs @@ -28,6 +28,7 @@ internal class LoggerBase( ILoggerWriter writer, ILoggerSettingsProvider settingsProvider) : ILogger { + public ILogger ForContext(params string[] context) => new LoggerBase( contextManager.CreateAugmentedContext(context.Where(x => !string.IsNullOrEmpty(x))), @@ -44,43 +45,49 @@ public void WriteLine(string message) => writer.WriteLine(CreateStandardLogPrefix().Append(message).ToString()); public void WriteLine(string messageFormat, params object[] args) => - writer.WriteLine(CreateStandardLogPrefix().AppendFormat(CultureInfo.CurrentCulture, messageFormat, args).ToString()); + WriteLine(default, messageFormat, args); + + public void WriteLine(MessageLevelContext context, string messageFormat, params object[] args) => + writer.WriteLine(CreateStandardLogPrefix(context).AppendFormat(CultureInfo.CurrentCulture, messageFormat, args).ToString()); + + public void LogVerbose(string messageFormat, params object[] args) => + LogVerbose(default, messageFormat, args); - public void LogVerbose(string messageFormat, params object[] args) + public void LogVerbose(MessageLevelContext context, string messageFormat, params object[] args) { if (!settingsProvider.IsVerboseEnabled) { return; } - var debugLogPrefix = CreateDebugLogPrefix(); + var debugLogPrefix = CreateDebugLogPrefix(context); var logLine = args.Length > 0 ? debugLogPrefix.AppendFormat(CultureInfo.CurrentCulture, messageFormat, args) : debugLogPrefix.Append(messageFormat); writer.WriteLine(logLine.ToString()); } - private StringBuilder CreateStandardLogPrefix() => - AddStandardProperties(new StringBuilder()); + private StringBuilder CreateStandardLogPrefix(MessageLevelContext context = default) => + AddStandardProperties(new StringBuilder(), context); - private StringBuilder CreateDebugLogPrefix() => - AddStandardProperties(AppendProperty(new StringBuilder(), "DEBUG")); + private StringBuilder CreateDebugLogPrefix(MessageLevelContext context = default) => + AddStandardProperties(AppendProperty(new StringBuilder(), "DEBUG"), context); - private StringBuilder AddStandardProperties(StringBuilder builder) + private StringBuilder AddStandardProperties(StringBuilder builder, MessageLevelContext context) { if (settingsProvider.IsThreadIdEnabled) { AppendPropertyFormat(builder, "ThreadId {0}", Thread.CurrentThread.ManagedThreadId); } - if (!string.IsNullOrEmpty(contextManager.FormatedContext)) + if (contextManager.GetFormattedContextOrNull(context) is var formatedContext && !string.IsNullOrEmpty(formatedContext)) { - AppendProperty(builder, contextManager.FormatedContext); + AppendProperty(builder, formatedContext); } - if (settingsProvider.IsVerboseEnabled && !string.IsNullOrEmpty(contextManager.FormatedVerboseContext)) + if (settingsProvider.IsVerboseEnabled && contextManager.GetFormattedVerboseContextOrNull(context) is var formattedVerboseContext && !string.IsNullOrEmpty(formattedVerboseContext)) { - AppendProperty(builder, contextManager.FormatedVerboseContext); + AppendProperty(builder, formattedVerboseContext); } return builder; diff --git a/src/Core/Logging/LoggerContextManager.cs b/src/Core/Logging/LoggerContextManager.cs index 25ac91fa1..6441fd78b 100644 --- a/src/Core/Logging/LoggerContextManager.cs +++ b/src/Core/Logging/LoggerContextManager.cs @@ -28,6 +28,7 @@ namespace SonarLint.VisualStudio.Core.Logging; [PartCreationPolicy(CreationPolicy.NonShared)] internal class LoggerContextManager : ILoggerContextManager { + private const string Separator = " > "; private readonly ImmutableList contexts; private readonly ImmutableList verboseContexts; private readonly Lazy formatedContext; @@ -44,12 +45,34 @@ private LoggerContextManager(ImmutableList contexts, ImmutableList(() => MergeContextsIntoSingleProperty(verboseContexts), LazyThreadSafetyMode.PublicationOnly); } - public string FormatedContext => formatedContext.Value; - public string FormatedVerboseContext => formatedVerboseContext.Value; + public string GetFormattedContextOrNull(MessageLevelContext messageLevelContext) => + GetContextInternal(formatedContext.Value, messageLevelContext.Context); + public string GetFormattedVerboseContextOrNull(MessageLevelContext messageLevelContext) => + GetContextInternal(formatedVerboseContext.Value, messageLevelContext.VerboseContext); public ILoggerContextManager CreateAugmentedContext(IEnumerable additionalContexts) => new LoggerContextManager(contexts.AddRange(additionalContexts), verboseContexts); public ILoggerContextManager CreateAugmentedVerboseContext(IEnumerable additionalVerboseContexts) => new LoggerContextManager(contexts, verboseContexts.AddRange(additionalVerboseContexts)); - private static string MergeContextsIntoSingleProperty(ImmutableList contexts) => contexts.Count > 0 ? string.Join(" > ", contexts) : null; + private static string GetContextInternal(string baseContext, IReadOnlyCollection messageLevelContext) + { + if (messageLevelContext is not { Count: > 0 }) + { + return baseContext; + } + + IEnumerable resultingContext = messageLevelContext; + if (baseContext != null) + { + resultingContext = resultingContext.Prepend(baseContext); + } + + return MergeContextsIntoSingleProperty(resultingContext); + } + + private static string MergeContextsIntoSingleProperty(IEnumerable contexts) + { + var joinResult = string.Join(Separator, contexts); + return string.IsNullOrEmpty(joinResult) ? null : joinResult; + } } diff --git a/src/TestInfrastructure/Framework/TestLogger.cs b/src/TestInfrastructure/Framework/TestLogger.cs index 832812fc1..ad21b614f 100644 --- a/src/TestInfrastructure/Framework/TestLogger.cs +++ b/src/TestInfrastructure/Framework/TestLogger.cs @@ -102,8 +102,12 @@ public void Reset() public void WriteLine(string messageFormat, params object[] args) => logger.WriteLine(messageFormat, args); + public void WriteLine(MessageLevelContext context, string messageFormat, params object[] args) => logger.WriteLine(context, messageFormat, args); + public void LogVerbose(string message, params object[] args) => logger.LogVerbose(message, args); + public void LogVerbose(MessageLevelContext context, string messageFormat, params object[] args) => logger.WriteLine(context, messageFormat, args); + public ILogger ForContext(params string[] context) => logger.ForContext(context); public ILogger ForVerboseContext(params string[] context) => logger.ForVerboseContext();