using Microsoft.AspNetCore.Http; using Serilog; using Serilog.Configuration; using Serilog.Core; using Serilog.Events; using System; namespace IRaCIS.Core.API { public static class EnricherExtensions { public static LoggerConfiguration WithHttpContextInfo(this LoggerEnrichmentConfiguration enrich, IServiceProvider serviceProvider) { if (enrich == null) throw new ArgumentNullException(nameof(enrich)); return enrich.With(new HttpContextEnricher(serviceProvider)); } public static LoggerConfiguration WithHttpContextInfo(this LoggerEnrichmentConfiguration enrich, IServiceProvider serviceProvider, Action enrichAction) { if (enrich == null) throw new ArgumentNullException(nameof(enrich)); return enrich.With(new HttpContextEnricher(serviceProvider, enrichAction)); } } }