Skip to content

Commit 0959fa9

Browse files
Hotfix/small fix of documentation (#5)
* small fix of documentation * small fix
1 parent 513492b commit 0959fa9

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed

GitVersion.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
next-version: 7.0.0 #
1+
next-version: 7.0.0 #.
22
branches:
33
master:
44
regex: ^master$|^main$
@@ -54,7 +54,7 @@ branches:
5454
regex: ^(pull|pull\-requests|pr|merge)[/-]
5555
mode: ContinuousDelivery
5656
tag: pr
57-
tag-number-pattern: '[/-](?<number>\d+)[-/]'
57+
tag-number-pattern: '(\d+)'
5858
increment: None
5959
source-branches:
6060
- dev

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ or
6161
{
6262
"Serilog": {
6363
"MinimumLevel": "Debug",
64-
"Using": [ "Serilog.Enrichers.ClientInfo" ],
64+
"Using": [ "Serilog.Enrichers.HttpContext" ],
6565
"Enrich": [
6666
{
6767
"Name": "WithClientIp",
@@ -87,7 +87,7 @@ or
8787
{
8888
"Serilog": {
8989
"MinimumLevel": "Debug",
90-
"Using": [ "Serilog.Enrichers.ClientInfo" ],
90+
"Using": [ "Serilog.Enrichers.HttpContext" ],
9191
"Enrich": [
9292
{
9393
"Name": "WithCorrelationId",
@@ -114,7 +114,7 @@ or
114114
{
115115
"Serilog": {
116116
"MinimumLevel": "Debug",
117-
"Using": [ "Serilog.Enrichers.ClientInfo" ],
117+
"Using": [ "Serilog.Enrichers.HttpContext" ],
118118
"Enrich": [
119119
{
120120
"Name": "WithRequestHeader",
@@ -135,7 +135,7 @@ or
135135
"propertyName": "RequestLength"
136136
}
137137
}
138-
],
138+
]
139139
}
140140
}
141141
```

src/Serilog.Enrichers.HttpContext/Enrichers/ClientHeaderEnricher.cs renamed to src/Serilog.Enrichers.HttpContext/Enrichers/RequestHeaderEnricher.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
namespace Serilog.Enrichers;
22

33
/// <inheritdoc/>
4-
public class ClientHeaderEnricher : ILogEventEnricher
4+
public class RequestHeaderEnricher : ILogEventEnricher
55
{
66
private readonly string _clientHeaderItemKey;
77
private readonly string _propertyName;
88
private readonly string _headerKey;
99
private readonly IHttpContextAccessor _contextAccessor;
1010

11-
public ClientHeaderEnricher(string headerKey, string propertyName)
11+
public RequestHeaderEnricher(string headerKey, string propertyName)
1212
: this(headerKey, propertyName, new HttpContextAccessor())
1313
{
1414
}
1515

16-
internal ClientHeaderEnricher(string headerKey, string propertyName, IHttpContextAccessor contextAccessor)
16+
internal RequestHeaderEnricher(string headerKey, string propertyName, IHttpContextAccessor contextAccessor)
1717
{
1818
_headerKey = headerKey;
1919
_propertyName = string.IsNullOrWhiteSpace(propertyName)
@@ -23,7 +23,7 @@ internal ClientHeaderEnricher(string headerKey, string propertyName, IHttpContex
2323
_contextAccessor = contextAccessor;
2424
}
2525

26-
internal ClientHeaderEnricher(IHttpContextAccessor contextAccessor)
26+
internal RequestHeaderEnricher(IHttpContextAccessor contextAccessor)
2727
{
2828
_contextAccessor = contextAccessor;
2929
}

src/Serilog.Enrichers.HttpContext/Extensions/HttpContextLoggerConfigurationExtensions.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,44 +60,44 @@ public static LoggerConfiguration WithCorrelationId(
6060
/// Registers the HTTP request header enricher to enrich logs with the header value.
6161
/// </summary>
6262
/// <param name="enrichmentConfiguration">The enrichment configuration.</param>
63-
/// <param name="propertyName">The property name of log</param>
64-
/// <param name="headerName">The header name to log its value</param>
6563
/// <exception cref="ArgumentNullException">enrichmentConfiguration</exception>
66-
/// <exception cref="ArgumentNullException">headerName</exception>
6764
/// <returns>The logger configuration so that multiple calls can be chained.</returns>
68-
public static LoggerConfiguration WithRequestHeader(
69-
this LoggerEnrichmentConfiguration enrichmentConfiguration,
70-
string headerName,
71-
string propertyName = null)
65+
public static LoggerConfiguration WithRequestBody(
66+
this LoggerEnrichmentConfiguration enrichmentConfiguration)
7267
{
7368
if (enrichmentConfiguration == null)
7469
{
7570
throw new ArgumentNullException(nameof(enrichmentConfiguration));
7671
}
7772

78-
if (headerName == null)
79-
{
80-
throw new ArgumentNullException(nameof(headerName));
81-
}
82-
83-
return enrichmentConfiguration.With(new ClientHeaderEnricher(headerName, propertyName));
73+
return enrichmentConfiguration.With(new RequestBodyEnricher());
8474
}
8575

8676
/// <summary>
8777
/// Registers the HTTP request header enricher to enrich logs with the header value.
8878
/// </summary>
8979
/// <param name="enrichmentConfiguration">The enrichment configuration.</param>
80+
/// <param name="propertyName">The property name of log</param>
81+
/// <param name="headerName">The header name to log its value</param>
9082
/// <exception cref="ArgumentNullException">enrichmentConfiguration</exception>
83+
/// <exception cref="ArgumentNullException">headerName</exception>
9184
/// <returns>The logger configuration so that multiple calls can be chained.</returns>
92-
public static LoggerConfiguration WithRequestBody(
93-
this LoggerEnrichmentConfiguration enrichmentConfiguration)
85+
public static LoggerConfiguration WithRequestHeader(
86+
this LoggerEnrichmentConfiguration enrichmentConfiguration,
87+
string headerName,
88+
string propertyName = null)
9489
{
9590
if (enrichmentConfiguration == null)
9691
{
9792
throw new ArgumentNullException(nameof(enrichmentConfiguration));
9893
}
9994

100-
return enrichmentConfiguration.With(new RequestBodyEnricher());
95+
if (headerName == null)
96+
{
97+
throw new ArgumentNullException(nameof(headerName));
98+
}
99+
100+
return enrichmentConfiguration.With(new RequestHeaderEnricher(headerName, propertyName));
101101
}
102102

103103
/// <summary>

test/Serilog.Enrichers.HttpContext.Tests/Enrichers/ClientHeaderEnricherTests.cs renamed to test/Serilog.Enrichers.HttpContext.Tests/Enrichers/RequestHeaderEnricherTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
namespace Serilog.Enrichers.HttpContext.Tests.Enrichers;
22

3-
public class ClientHeaderEnricherTests
3+
public class RequestHeaderEnricherTests
44
{
55
private readonly IHttpContextAccessor _contextAccessor;
66

7-
public ClientHeaderEnricherTests()
7+
public RequestHeaderEnricherTests()
88
{
99
var httpContext = new DefaultHttpContext();
1010
_contextAccessor = Substitute.For<IHttpContextAccessor>();
@@ -20,7 +20,7 @@ public void EnrichLogWithClientHeader_WhenHttpRequestContainHeader_ShouldCreateN
2020
var headerValue = Guid.NewGuid().ToString();
2121
_contextAccessor.HttpContext.Request.Headers.Add(headerKey, headerValue);
2222

23-
var clientHeaderEnricher = new ClientHeaderEnricher(headerKey, propertyName, _contextAccessor);
23+
var clientHeaderEnricher = new RequestHeaderEnricher(headerKey, propertyName, _contextAccessor);
2424

2525
LogEvent evt = null;
2626
var log = new LoggerConfiguration()
@@ -46,7 +46,7 @@ public void EnrichLogWithClientHeader_WhenHttpRequestContainHeader_ShouldCreateH
4646
var headerValue = Guid.NewGuid().ToString();
4747
_contextAccessor.HttpContext.Request.Headers.Add(headerKey, headerValue);
4848

49-
var clientHeaderEnricher = new ClientHeaderEnricher(headerKey, propertyName:string.Empty, _contextAccessor);
49+
var clientHeaderEnricher = new RequestHeaderEnricher(headerKey, propertyName:string.Empty, _contextAccessor);
5050

5151
LogEvent evt = null;
5252
var log = new LoggerConfiguration()
@@ -75,8 +75,8 @@ public void EnrichLogWithMulitpleClientHeaderEnricher_WhenHttpRequestContainHead
7575
_contextAccessor.HttpContext.Request.Headers.Add(headerKey1, headerValue1);
7676
_contextAccessor.HttpContext.Request.Headers.Add(headerKey2, headerValue2);
7777

78-
var clientHeaderEnricher1 = new ClientHeaderEnricher(headerKey1, propertyName:string.Empty, _contextAccessor);
79-
var clientHeaderEnricher2 = new ClientHeaderEnricher(headerKey2, propertyName:string.Empty, _contextAccessor);
78+
var clientHeaderEnricher1 = new RequestHeaderEnricher(headerKey1, propertyName:string.Empty, _contextAccessor);
79+
var clientHeaderEnricher2 = new RequestHeaderEnricher(headerKey2, propertyName:string.Empty, _contextAccessor);
8080

8181
LogEvent evt = null;
8282
var log = new LoggerConfiguration()
@@ -102,7 +102,7 @@ public void EnrichLogWithClientHeader_WhenHttpRequestNotContainHeader_ShouldCrea
102102
{
103103
// Arrange
104104
var headerKey = "RequestId";
105-
var clientHeaderEnricher = new ClientHeaderEnricher(headerKey, propertyName:string.Empty, _contextAccessor);
105+
var clientHeaderEnricher = new RequestHeaderEnricher(headerKey, propertyName:string.Empty, _contextAccessor);
106106

107107
LogEvent evt = null;
108108
var log = new LoggerConfiguration()

0 commit comments

Comments
 (0)