30 lines
		
	
	
		
			970 B
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			970 B
		
	
	
	
		
			C#
		
	
	
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<LogEvent, ILogEventPropertyFactory, HttpContext> enrichAction)
 | 
						|
        {
 | 
						|
            if (enrich == null)
 | 
						|
                throw new ArgumentNullException(nameof(enrich));
 | 
						|
 | 
						|
            return enrich.With(new HttpContextEnricher(serviceProvider, enrichAction));
 | 
						|
        }
 | 
						|
 | 
						|
    }
 | 
						|
 | 
						|
}
 |