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

- Removed existing logger scopes as we want to minimize the number of sc... #172

Merged
merged 1 commit into from
Apr 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

122 changes: 0 additions & 122 deletions src/Microsoft.AspNet.Routing/Logging/TemplateRouteRouteAsyncValues.cs

This file was deleted.

53 changes: 15 additions & 38 deletions src/Microsoft.AspNet.Routing/RouteCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class RouteCollection : IRouteCollection
private readonly Dictionary<string, INamedRouter> _namedRoutes =
new Dictionary<string, INamedRouter>(StringComparer.OrdinalIgnoreCase);

private ILogger _logger;
private RouteOptions _options;

public IRouter this[int index]
Expand Down Expand Up @@ -55,44 +54,31 @@ public void Add([NotNull] IRouter router)

public async virtual Task RouteAsync(RouteContext context)
{
EnsureLogger(context.HttpContext);
using (_logger.BeginScope("RouteCollection.RouteAsync"))
for (var i = 0; i < Count; i++)
{
for (var i = 0; i < Count; i++)
{
var route = this[i];
var route = this[i];

var oldRouteData = context.RouteData;
var oldRouteData = context.RouteData;

var newRouteData = new RouteData(oldRouteData);
newRouteData.Routers.Add(route);
var newRouteData = new RouteData(oldRouteData);
newRouteData.Routers.Add(route);

try
{
context.RouteData = newRouteData;
try
{
context.RouteData = newRouteData;

await route.RouteAsync(context);
if (context.IsHandled)
{
break;
}
}
finally
await route.RouteAsync(context);
if (context.IsHandled)
{
if (!context.IsHandled)
{
context.RouteData = oldRouteData;
}
break;
}
}

if (_logger.IsEnabled(LogLevel.Verbose))
finally
{
_logger.WriteValues(new RouteCollectionRouteAsyncValues()
if (!context.IsHandled)
{
Handled = context.IsHandled,
Routes = _routes
});
context.RouteData = oldRouteData;
}
}
}
}
Expand Down Expand Up @@ -241,15 +227,6 @@ private PathString NormalizeVirtualPath(PathString path)
return path;
}

private void EnsureLogger(HttpContext context)
{
if (_logger == null)
{
var factory = context.RequestServices.GetRequiredService<ILoggerFactory>();
_logger = factory.CreateLogger<RouteCollection>();
}
}

private void EnsureOptions(HttpContext context)
{
if (_options == null)
Expand Down
Loading