Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Commit f7be877

Browse files
lodejardrynowak
authored andcommitted
Using HttpContext property instead of feature interface
1 parent c3a76db commit f7be877

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/Microsoft.AspNet.Hosting/Internal/HostingLoggerExtensions.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Generic;
66
using System.Threading;
77
using Microsoft.AspNet.Http;
8-
using Microsoft.AspNet.Http.Features;
98
using Microsoft.Extensions.Logging;
109

1110
namespace Microsoft.AspNet.Hosting.Internal
@@ -47,29 +46,24 @@ private class HostingRequestScope : ILogValues
4746
{
4847
private readonly HttpContext _httpContext;
4948

50-
private FeatureReference<IHttpRequestIdentifierFeature> _requestIdentifierFeatureReference;
51-
private IEnumerable<KeyValuePair<string, object>> _cachedGetValues;
5249
private string _cachedToString;
50+
private IEnumerable<KeyValuePair<string, object>> _cachedGetValues;
5351

5452
public HostingRequestScope(HttpContext httpContext)
5553
{
5654
_httpContext = httpContext;
5755
}
5856

59-
public IHttpRequestIdentifierFeature RequestIdFeature =>
60-
_requestIdentifierFeatureReference.Fetch(_httpContext.Features) ??
61-
_requestIdentifierFeatureReference.Update(_httpContext.Features, new FastHttpRequestIdentifierFeature());
62-
6357
public override string ToString() => _cachedToString ?? Interlocked.CompareExchange(
6458
ref _cachedToString,
65-
$"RequestId:{RequestIdFeature.TraceIdentifier} RequestPath:{_httpContext.Request.Path}",
59+
$"RequestId:{_httpContext.TraceIdentifier} RequestPath:{_httpContext.Request.Path}",
6660
null);
6761

6862
public IEnumerable<KeyValuePair<string, object>> GetValues() => _cachedGetValues ?? Interlocked.CompareExchange(
6963
ref _cachedGetValues,
7064
new[]
7165
{
72-
new KeyValuePair<string, object>("RequestId", RequestIdFeature.TraceIdentifier),
66+
new KeyValuePair<string, object>("RequestId", _httpContext.TraceIdentifier),
7367
new KeyValuePair<string, object>("RequestPath", _httpContext.Request.Path.ToString()),
7468
},
7569
null);
@@ -80,8 +74,9 @@ private class HostingRequestStarting : ILogValues
8074
internal static readonly Func<object, Exception, string> Callback = (state, exception) => ((HostingRequestStarting)state).ToString();
8175

8276
private readonly HttpContext _httpContext;
83-
private IEnumerable<KeyValuePair<string, object>> _cachedGetValues;
77+
8478
private string _cachedToString;
79+
private IEnumerable<KeyValuePair<string, object>> _cachedGetValues;
8580

8681
public HostingRequestStarting(HttpContext httpContext)
8782
{
@@ -116,6 +111,7 @@ private class HostingRequestFinished
116111
internal static readonly Func<object, Exception, string> Callback = (state, exception) => ((HostingRequestFinished)state).ToString();
117112

118113
private readonly HttpContext _httpContext;
114+
119115
private IEnumerable<KeyValuePair<string, object>> _cachedGetValues;
120116
private string _cachedToString;
121117

0 commit comments

Comments
 (0)