[docs-logs] Use struct in the complex type logging demo (#5577)
Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
This commit is contained in:
parent
dffe70c8cc
commit
c2558da11f
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
public class FoodRecallNotice
|
||||
public struct FoodRecallNotice
|
||||
{
|
||||
public string? BrandName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -34,5 +34,5 @@ internal static partial class LoggerExtensions
|
|||
[LoggerMessage(LogLevel.Critical)]
|
||||
public static partial void FoodRecallNotice(
|
||||
this ILogger logger,
|
||||
[LogProperties(OmitReferenceName = true)] FoodRecallNotice foodRecallNotice);
|
||||
[LogProperties(OmitReferenceName = true)] in FoodRecallNotice foodRecallNotice);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,16 +30,12 @@ dotnet add package Microsoft.Extensions.Telemetry.Abstractions
|
|||
Define a new complex data type, as shown in [FoodRecallNotice.cs](./FoodRecallNotice.cs):
|
||||
|
||||
```csharp
|
||||
public class FoodRecallNotice
|
||||
public struct FoodRecallNotice
|
||||
{
|
||||
public string? BrandName { get; set; }
|
||||
|
||||
public string? ProductDescription { get; set; }
|
||||
|
||||
public string? ProductType { get; set; }
|
||||
|
||||
public string? RecallReasonDescription { get; set; }
|
||||
|
||||
public string? CompanyName { get; set; }
|
||||
}
|
||||
```
|
||||
|
|
@ -54,7 +50,7 @@ internal static partial class LoggerExtensions
|
|||
[LoggerMessage(LogLevel.Critical)]
|
||||
public static partial void FoodRecallNotice(
|
||||
this ILogger logger,
|
||||
[LogProperties(OmitReferenceName = true)] FoodRecallNotice foodRecallNotice);
|
||||
[LogProperties(OmitReferenceName = true)] in FoodRecallNotice foodRecallNotice);
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Telemetry.Abstractions" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue