diff --git a/src/ZLogger/ZLoggerInterpolatedStringHandler.LogLevel.cs b/src/ZLogger/ZLoggerInterpolatedStringHandler.LogLevel.cs index 3fc498f5..f24011ce 100644 --- a/src/ZLogger/ZLoggerInterpolatedStringHandler.LogLevel.cs +++ b/src/ZLogger/ZLoggerInterpolatedStringHandler.LogLevel.cs @@ -29,9 +29,9 @@ public void AppendFormatted(Nullable value, int alignment = 0, string? for this.innerHandler.AppendFormatted(value, alignment, format, argumentName); } - public void AppendFormatted(ZLoggerNamedParam value, int alignment = 0, string? format = null, string? _ = null) + public void AppendFormatted((string, T) namedValue, int alignment = 0, string? format = null, string? _ = null) { - this.innerHandler.AppendFormatted(value, alignment, format); + this.innerHandler.AppendFormatted(namedValue, alignment, format); } } @@ -60,9 +60,9 @@ public void AppendFormatted(Nullable value, int alignment = 0, string? for this.innerHandler.AppendFormatted(value, alignment, format, argumentName); } - public void AppendFormatted(ZLoggerNamedParam value, int alignment = 0, string? format = null, string? _ = null) + public void AppendFormatted((string, T) namedValue, int alignment = 0, string? format = null, string? _ = null) { - this.innerHandler.AppendFormatted(value, alignment, format); + this.innerHandler.AppendFormatted(namedValue, alignment, format); } } @@ -91,9 +91,9 @@ public void AppendFormatted(Nullable value, int alignment = 0, string? for this.innerHandler.AppendFormatted(value, alignment, format, argumentName); } - public void AppendFormatted(ZLoggerNamedParam value, int alignment = 0, string? format = null, string? _ = null) + public void AppendFormatted((string, T) namedValue, int alignment = 0, string? format = null, string? _ = null) { - this.innerHandler.AppendFormatted(value, alignment, format); + this.innerHandler.AppendFormatted(namedValue, alignment, format); } } @@ -122,9 +122,9 @@ public void AppendFormatted(Nullable value, int alignment = 0, string? for this.innerHandler.AppendFormatted(value, alignment, format, argumentName); } - public void AppendFormatted(ZLoggerNamedParam value, int alignment = 0, string? format = null, string? _ = null) + public void AppendFormatted((string, T) namedValue, int alignment = 0, string? format = null, string? _ = null) { - this.innerHandler.AppendFormatted(value, alignment, format); + this.innerHandler.AppendFormatted(namedValue, alignment, format); } } @@ -153,9 +153,9 @@ public void AppendFormatted(Nullable value, int alignment = 0, string? for this.innerHandler.AppendFormatted(value, alignment, format, argumentName); } - public void AppendFormatted(ZLoggerNamedParam value, int alignment = 0, string? format = null, string? _ = null) + public void AppendFormatted((string, T) namedValue, int alignment = 0, string? format = null, string? _ = null) { - this.innerHandler.AppendFormatted(value, alignment, format); + this.innerHandler.AppendFormatted(namedValue, alignment, format); } } @@ -184,9 +184,9 @@ public void AppendFormatted(Nullable value, int alignment = 0, string? for this.innerHandler.AppendFormatted(value, alignment, format, argumentName); } - public void AppendFormatted(ZLoggerNamedParam value, int alignment = 0, string? format = null, string? _ = null) + public void AppendFormatted((string, T) namedValue, int alignment = 0, string? format = null, string? _ = null) { - this.innerHandler.AppendFormatted(value, alignment, format); + this.innerHandler.AppendFormatted(namedValue, alignment, format); } } diff --git a/src/ZLogger/ZLoggerInterpolatedStringHandler.LogLevel.tt b/src/ZLogger/ZLoggerInterpolatedStringHandler.LogLevel.tt index 39413fa8..ff121695 100644 --- a/src/ZLogger/ZLoggerInterpolatedStringHandler.LogLevel.tt +++ b/src/ZLogger/ZLoggerInterpolatedStringHandler.LogLevel.tt @@ -39,9 +39,9 @@ public ref struct ZLogger<#= logLevel #>InterpolatedStringHandler this.innerHandler.AppendFormatted(value, alignment, format, argumentName); } - public void AppendFormatted(ZLoggerNamedParam value, int alignment = 0, string? format = null, string? _ = null) + public void AppendFormatted((string, T) namedValue, int alignment = 0, string? format = null, string? _ = null) { - this.innerHandler.AppendFormatted(value, alignment, format); + this.innerHandler.AppendFormatted(namedValue, alignment, format); } } diff --git a/src/ZLogger/ZLoggerInterpolatedStringHandler.cs b/src/ZLogger/ZLoggerInterpolatedStringHandler.cs index e444cf9c..2844a822 100644 --- a/src/ZLogger/ZLoggerInterpolatedStringHandler.cs +++ b/src/ZLogger/ZLoggerInterpolatedStringHandler.cs @@ -109,9 +109,9 @@ public void AppendFormatted(Nullable value, int alignment = 0, string? for } } - public void AppendFormatted(ZLoggerNamedParam value, int alignment = 0, string? format = null, string? _ = null) + public void AppendFormatted((string, T) namedValue, int alignment = 0, string? format = null, string? _ = null) { - AppendFormatted(value.Value, alignment, format, value.Name); + AppendFormatted(namedValue.Item2, alignment, format, namedValue.Item1); } internal InterpolatedStringLogState GetStateAndClear() diff --git a/src/ZLogger/ZLoggerParam.cs b/src/ZLogger/ZLoggerParam.cs deleted file mode 100644 index f95c24b4..00000000 --- a/src/ZLogger/ZLoggerParam.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace ZLogger -{ - // The helper class used directly with logger - public static partial class ZLogger - { - public static ZLoggerNamedParam Param(string name, T value) => new(name, value); - } - - public readonly struct ZLoggerNamedParam - { - public readonly string Name; - public readonly T Value; - - public ZLoggerNamedParam(string name, T value) - { - Name = name; - Value = value; - } - } -} diff --git a/tests/ZLogger.Tests/NamedParamTest.cs b/tests/ZLogger.Tests/NamedParamTest.cs index 6e333689..b3f75a18 100644 --- a/tests/ZLogger.Tests/NamedParamTest.cs +++ b/tests/ZLogger.Tests/NamedParamTest.cs @@ -22,7 +22,7 @@ public void StructuredLoggingOptions() }); var logger = loggerFactory.CreateLogger("test"); - logger.ZLogInformation($"{ZLogger.Param("TAKO", 100)} {ZLogger.Param("YAKI", 200):D5} {ZLogger.Param("T", new DateTime(2023, 12, 31)),15:yyyy-MM-dd}"); + logger.ZLogInformation($"{("TAKO", 100)} {("YAKI", 200):D5} {("T", new DateTime(2023, 12, 31)),15:yyyy-MM-dd}"); var json = processor.EntryMessages.Dequeue(); var doc = JsonDocument.Parse(json).RootElement;