Files
EonaCat.LogStack/EonaCat.LogStack/EonaCatLoggerCore/Boosters/ContextEnrichmentBooster.cs
T
2026-06-16 21:46:16 +02:00

32 lines
793 B
C#

using EonaCat.LogStack.Core;
using System;
namespace EonaCat.LogStack.Boosters;
/// <summary>
/// Context enrichment booster that adds contextual information
/// </summary>
public sealed class ContextEnrichmentBooster : BoosterBase
{
private readonly Func<LogEventBuilder, LogEventBuilder> _enricher;
public ContextEnrichmentBooster(Func<LogEventBuilder, LogEventBuilder> enricher)
: base("ContextEnrichment")
{
_enricher = enricher ?? throw new ArgumentNullException(nameof(enricher));
}
public override bool Boost(ref LogEventBuilder builder)
{
try
{
builder = _enricher(builder);
return true;
}
catch
{
return true; // Don't filter on enrichment error
}
}
}