This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from dgarciarubio/app-settings
App settings support by adding specific extension methods solves #8
- Loading branch information
Showing
12 changed files
with
142 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/SerilogWeb.Classic.Mvc/SerilogWebClassicMvcLoggerConfigurationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using Serilog.Configuration; | ||
using SerilogWeb.Classic.Mvc.Enrichers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Serilog | ||
{ | ||
/// <summary> | ||
/// Extends <see cref="LoggerConfiguration"/> to add enrichers for SerilogWeb.Classic.Mvc logging module | ||
/// </summary> | ||
public static class SerilogWebClassicMvcLoggerConfigurationExtensions | ||
{ | ||
/// <summary> | ||
/// Enrich log events with the name of the current MVC action. | ||
/// </summary> | ||
/// <param name="enrichmentConfiguration">Logger enrichment configuration.</param> | ||
/// <param name="propertyName">Name of the property to log.</param> | ||
/// <returns>Configuration object allowing method chaining.</returns> | ||
public static LoggerConfiguration WithMvcActionName( | ||
this LoggerEnrichmentConfiguration enrichmentConfiguration, | ||
string propertyName = MvcActionNameEnricher.MvcActionPropertyName) | ||
{ | ||
if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration)); | ||
return enrichmentConfiguration.With(new MvcActionNameEnricher(propertyName)); | ||
} | ||
|
||
/// <summary> | ||
/// Enrich log events with the controller name for the current MVC action. | ||
/// </summary> | ||
/// <param name="enrichmentConfiguration">Logger enrichment configuration.</param> | ||
/// <param name="propertyName">Name of the property to log.</param> | ||
/// <returns>Configuration object allowing method chaining.</returns> | ||
public static LoggerConfiguration WithMvcControllerName( | ||
this LoggerEnrichmentConfiguration enrichmentConfiguration, | ||
string propertyName = MvcControllerNameEnricher.MvcControllerPropertyName) | ||
{ | ||
if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration)); | ||
return enrichmentConfiguration.With(new MvcControllerNameEnricher(propertyName)); | ||
} | ||
|
||
/// <summary> | ||
/// Enrich log events with the route data for the current MVC action. | ||
/// </summary> | ||
/// <param name="enrichmentConfiguration">Logger enrichment configuration.</param> | ||
/// <param name="propertyName">Name of the property to log.</param> | ||
/// <returns>Configuration object allowing method chaining.</returns> | ||
public static LoggerConfiguration WithMvcRouteData( | ||
this LoggerEnrichmentConfiguration enrichmentConfiguration, | ||
string propertyName = MvcRouteDataEnricher.MvcRouteDataPropertyName) | ||
{ | ||
if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration)); | ||
return enrichmentConfiguration.With(new MvcRouteDataEnricher(propertyName)); | ||
} | ||
|
||
/// <summary> | ||
/// Enrich log events with the template for the current MVC action. | ||
/// </summary> | ||
/// <param name="enrichmentConfiguration">Logger enrichment configuration.</param> | ||
/// <param name="propertyName">Name of the property to log.</param> | ||
/// <returns>Configuration object allowing method chaining.</returns> | ||
public static LoggerConfiguration WithMvcRouteTemplate( | ||
this LoggerEnrichmentConfiguration enrichmentConfiguration, | ||
string propertyName = MvcRouteTemplateEnricher.MvcRouteTemplatePropertyName) | ||
{ | ||
if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration)); | ||
return enrichmentConfiguration.With(new MvcRouteTemplateEnricher(propertyName)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters