Skip to content

Commit

Permalink
Extended LogEventConverter.ConvertToEcs<>() (#460)
Browse files Browse the repository at this point in the history
Extended LogEventConverter.ConvertToEcs<>() with an optional
EcsDocumentCreationCache input parameter that gets passed into
EcsDocument.CreateNewWithDefaults<>()

This is to support overwrites of static data such as those in
EcsDocument.Service

Co-authored-by: Martijn Laarman <[email protected]>
  • Loading branch information
bsnsaxo and Mpdreamz authored Feb 26, 2025
1 parent 7eee1b3 commit 2df5d15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Elastic.CommonSchema.Serilog/LogEventConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public static class LogEventConverter
/// <summary>
/// Converts a <see cref="LogEvent"/> to an <typeparamref name="TEcsDocument"/>
/// </summary>
public static TEcsDocument ConvertToEcs<TEcsDocument>(LogEvent logEvent, IEcsTextFormatterConfiguration<TEcsDocument> configuration)
public static TEcsDocument ConvertToEcs<TEcsDocument>(LogEvent logEvent, IEcsTextFormatterConfiguration<TEcsDocument> configuration, EcsDocumentCreationCache? initialCache = null)
where TEcsDocument : EcsDocument, new()
{
var ecsEvent = EcsDocument.CreateNewWithDefaults<TEcsDocument>(logEvent.Timestamp, logEvent.Exception, configuration);
var ecsEvent = EcsDocument.CreateNewWithDefaults<TEcsDocument>(logEvent.Timestamp, logEvent.Exception, configuration, initialCache);

if (logEvent.TryGetScalarString(SpecialKeys.MachineName, out var machineName))
{
Expand Down

0 comments on commit 2df5d15

Please sign in to comment.