Skip to content

Commit

Permalink
Reproduce #402
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Sep 23, 2024
1 parent 9ec7e0c commit f8ff80a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/Elastic.CommonSchema.Serilog.Tests/Repro/GithubIssue402.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Linq;
using FluentAssertions;
using Serilog.Context;
using Xunit;
using Xunit.Abstractions;

namespace Elastic.CommonSchema.Serilog.Tests.Repro;

public class GithubIssue402 : LogTestsBase
{
public GithubIssue402(ITestOutputHelper output) : base(output) { }

[Fact]
public void Reproduce() => TestLogger((logger, getLogEvents) =>
{
using (LogContext.PushProperty("client.user.id", "regis"))
logger.Information("Logging something with log context");

var logEvents = getLogEvents();
logEvents.Should().HaveCount(1);

var ecsEvents = ToEcsEvents(logEvents);

var (_, info) = ecsEvents.First();
info.Message.Should().Be("Logging something with log context");

info.Client.User.Id.Should().Be("regis");
//info.Labels.Should().NotBeNull().And.ContainKey("client.user.id");
//info.Labels["ShipmentId"].Should().Be("my-shipment-id");

//info.Metadata.Should().NotBeNull().And.ContainKey("ShipmentAmount");
//info.Metadata["ShipmentAmount"].Should().Be(2.3);

});
}

0 comments on commit f8ff80a

Please sign in to comment.