Reacting to ILogger api changes

This commit is contained in:
Kiran Challa 2015-04-04 02:52:43 -07:00
parent 5c29efc49c
commit 9330789fe3
25 changed files with 24 additions and 98 deletions

View File

@ -47,10 +47,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// Whether the action constraint is an <see cref="IActionConstraintFactory"/>. /// Whether the action constraint is an <see cref="IActionConstraintFactory"/>.
/// </summary> /// </summary>
public bool IsFactory { get; } public bool IsFactory { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -117,10 +117,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// See <see cref="ControllerActionDescriptor.ControllerTypeInfo"/>. /// See <see cref="ControllerActionDescriptor.ControllerTypeInfo"/>.
/// </summary> /// </summary>
public TypeInfo ControllerTypeInfo { get; } public TypeInfo ControllerTypeInfo { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -91,10 +91,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// Gets the set of properties associated with the action <see cref="ActionModel.Properties"/>. /// Gets the set of properties associated with the action <see cref="ActionModel.Properties"/>.
/// </summary> /// </summary>
public IDictionary<object, object> Properties { get; } public IDictionary<object, object> Properties { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -29,10 +29,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// See <see cref="ApiExplorerModel.GroupName"/>. /// See <see cref="ApiExplorerModel.GroupName"/>.
/// </summary> /// </summary>
public string GroupName { get; } public string GroupName { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -37,10 +37,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// Whether or not the assembly is dynamic. See <see cref="Assembly.IsDynamic"/>. /// Whether or not the assembly is dynamic. See <see cref="Assembly.IsDynamic"/>.
/// </summary> /// </summary>
public bool IsDynamic { get; } public bool IsDynamic { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -33,10 +33,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// The name of the route. See <see cref="AttributeRouteInfo.Name"/>. /// The name of the route. See <see cref="AttributeRouteInfo.Name"/>.
/// </summary> /// </summary>
public string Name { get; } public string Name { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -42,10 +42,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// Whether or not the template is absolute. See <see cref="AttributeRouteModel.IsAbsoluteTemplate"/>. /// Whether or not the template is absolute. See <see cref="AttributeRouteModel.IsAbsoluteTemplate"/>.
/// </summary> /// </summary>
public bool IsAbsoluteTemplate { get; } public bool IsAbsoluteTemplate { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -94,10 +94,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// Gets the set of properties associated with the controller <see cref="ControllerModel.Properties"/>. /// Gets the set of properties associated with the controller <see cref="ControllerModel.Properties"/>.
/// </summary> /// </summary>
public IDictionary<object, object> Properties { get; } public IDictionary<object, object> Properties { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -34,10 +34,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// The filter scope. See <see cref="FilterDescriptor.Scope"/>. /// The filter scope. See <see cref="FilterDescriptor.Scope"/>.
/// </summary> /// </summary>
public int Scope { get; } public int Scope { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -60,10 +60,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// A list of interfaces the <see cref="IFilter"/> implements. /// A list of interfaces the <see cref="IFilter"/> implements.
/// </summary> /// </summary>
public IList<Type> FilterInterfaces { get; } public IList<Type> FilterInterfaces { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -28,10 +28,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// The <see cref="Type"/> of the parameter. See <see cref="ParameterDescriptor.ParameterType"/>. /// The <see cref="Type"/> of the parameter. See <see cref="ParameterDescriptor.ParameterType"/>.
/// </summary> /// </summary>
public Type ParameterType { get; } public Type ParameterType { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -30,10 +30,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// The <see cref="Type"/> of the parameter. /// The <see cref="Type"/> of the parameter.
/// </summary> /// </summary>
public Type ParameterType { get; } public Type ParameterType { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -30,10 +30,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// The <see cref="Type"/> of the property. /// The <see cref="Type"/> of the property.
/// </summary> /// </summary>
public Type PropertyType { get; } public Type PropertyType { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -39,10 +39,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// See <see cref="IRouteConstraintProvider.BlockNonAttributedActions"/>. /// See <see cref="IRouteConstraintProvider.BlockNonAttributedActions"/>.
/// </summary> /// </summary>
public bool BlockNonAttributedActions { get; } public bool BlockNonAttributedActions { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -33,10 +33,5 @@ namespace Microsoft.AspNet.Mvc.Logging
/// The <see cref="RouteKeyHandling"/>. See <see cref="RouteDataActionConstraint.KeyHandling"/>. /// The <see cref="RouteKeyHandling"/>. See <see cref="RouteDataActionConstraint.KeyHandling"/>.
/// </summary> /// </summary>
public RouteKeyHandling KeyHandling { get; } public RouteKeyHandling KeyHandling { get; }
public override string Format()
{
return LogFormatter.FormatLogValues(this);
}
} }
} }

View File

@ -44,13 +44,13 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal(1, sink.Scopes.Count); Assert.Equal(1, sink.Scopes.Count);
var scope = sink.Scopes[0]; var scope = sink.Scopes[0];
Assert.Equal(typeof(DefaultActionSelector).FullName, scope.LoggerName); Assert.Equal(typeof(DefaultActionSelector).FullName, scope.LoggerName);
Assert.Equal("DefaultActionSelector.SelectAsync", scope.Scope); Assert.Equal("DefaultActionSelector.SelectAsync", scope.Scope.ToString());
Assert.Equal(1, sink.Writes.Count); Assert.Equal(1, sink.Writes.Count);
var write = sink.Writes[0]; var write = sink.Writes[0];
Assert.Equal(typeof(DefaultActionSelector).FullName, write.LoggerName); Assert.Equal(typeof(DefaultActionSelector).FullName, write.LoggerName);
Assert.Equal("DefaultActionSelector.SelectAsync", write.Scope); Assert.Equal("DefaultActionSelector.SelectAsync", write.Scope.ToString());
var values = Assert.IsType<DefaultActionSelectorSelectAsyncValues>(write.State); var values = Assert.IsType<DefaultActionSelectorSelectAsyncValues>(write.State);
Assert.Equal("DefaultActionSelector.SelectAsync", values.Name); Assert.Equal("DefaultActionSelector.SelectAsync", values.Name);
Assert.Empty(values.ActionsMatchingRouteConstraints); Assert.Empty(values.ActionsMatchingRouteConstraints);
@ -95,13 +95,13 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal(1, sink.Scopes.Count); Assert.Equal(1, sink.Scopes.Count);
var scope = sink.Scopes[0]; var scope = sink.Scopes[0];
Assert.Equal(typeof(DefaultActionSelector).FullName, scope.LoggerName); Assert.Equal(typeof(DefaultActionSelector).FullName, scope.LoggerName);
Assert.Equal("DefaultActionSelector.SelectAsync", scope.Scope); Assert.Equal("DefaultActionSelector.SelectAsync", scope.Scope.ToString());
Assert.Equal(1, sink.Writes.Count); Assert.Equal(1, sink.Writes.Count);
var write = sink.Writes[0]; var write = sink.Writes[0];
Assert.Equal(typeof(DefaultActionSelector).FullName, write.LoggerName); Assert.Equal(typeof(DefaultActionSelector).FullName, write.LoggerName);
Assert.Equal("DefaultActionSelector.SelectAsync", write.Scope); Assert.Equal("DefaultActionSelector.SelectAsync", write.Scope.ToString());
var values = Assert.IsType<DefaultActionSelectorSelectAsyncValues>(write.State); var values = Assert.IsType<DefaultActionSelectorSelectAsyncValues>(write.State);
Assert.Equal("DefaultActionSelector.SelectAsync", values.Name); Assert.Equal("DefaultActionSelector.SelectAsync", values.Name);
Assert.Equal<ActionDescriptor>(actions, values.ActionsMatchingRouteConstraints); Assert.Equal<ActionDescriptor>(actions, values.ActionsMatchingRouteConstraints);
@ -137,13 +137,13 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal(1, sink.Scopes.Count); Assert.Equal(1, sink.Scopes.Count);
var scope = sink.Scopes[0]; var scope = sink.Scopes[0];
Assert.Equal(typeof(DefaultActionSelector).FullName, scope.LoggerName); Assert.Equal(typeof(DefaultActionSelector).FullName, scope.LoggerName);
Assert.Equal("DefaultActionSelector.SelectAsync", scope.Scope); Assert.Equal("DefaultActionSelector.SelectAsync", scope.Scope.ToString());
Assert.Equal(1, sink.Writes.Count); Assert.Equal(1, sink.Writes.Count);
var write = sink.Writes[0]; var write = sink.Writes[0];
Assert.Equal(typeof(DefaultActionSelector).FullName, write.LoggerName); Assert.Equal(typeof(DefaultActionSelector).FullName, write.LoggerName);
Assert.Equal("DefaultActionSelector.SelectAsync", write.Scope); Assert.Equal("DefaultActionSelector.SelectAsync", write.Scope.ToString());
var values = Assert.IsType<DefaultActionSelectorSelectAsyncValues>(write.State); var values = Assert.IsType<DefaultActionSelectorSelectAsyncValues>(write.State);
Assert.Equal("DefaultActionSelector.SelectAsync", values.Name); Assert.Equal("DefaultActionSelector.SelectAsync", values.Name);
Assert.Equal<ActionDescriptor>(actions, values.ActionsMatchingRouteConstraints); Assert.Equal<ActionDescriptor>(actions, values.ActionsMatchingRouteConstraints);

View File

@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Mvc
{ {
public static NullLogger Instance = new NullLogger(); public static NullLogger Instance = new NullLogger();
public IDisposable BeginScope(object state) public IDisposable BeginScopeImpl(object state)
{ {
return NullDisposable.Instance; return NullDisposable.Instance;
} }

View File

@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc
public string Name { get; set; } public string Name { get; set; }
public IDisposable BeginScope(object state) public IDisposable BeginScopeImpl(object state)
{ {
_scope = state; _scope = state;

View File

@ -34,11 +34,11 @@ namespace Microsoft.AspNet.Mvc
// Assert // Assert
var scope = Assert.Single(sink.Scopes); var scope = Assert.Single(sink.Scopes);
Assert.Equal(typeof(MvcRouteHandler).FullName, scope.LoggerName); Assert.Equal(typeof(MvcRouteHandler).FullName, scope.LoggerName);
Assert.Equal("MvcRouteHandler.RouteAsync", scope.Scope); Assert.Equal("MvcRouteHandler.RouteAsync", scope.Scope.ToString());
var write = Assert.Single(sink.Writes); var write = Assert.Single(sink.Writes);
Assert.Equal(typeof(MvcRouteHandler).FullName, write.LoggerName); Assert.Equal(typeof(MvcRouteHandler).FullName, write.LoggerName);
Assert.Equal("MvcRouteHandler.RouteAsync", write.Scope); Assert.Equal("MvcRouteHandler.RouteAsync", write.Scope.ToString());
var values = Assert.IsType<MvcRouteHandlerRouteAsyncValues>(write.State); var values = Assert.IsType<MvcRouteHandlerRouteAsyncValues>(write.State);
Assert.Equal("MvcRouteHandler.RouteAsync", values.Name); Assert.Equal("MvcRouteHandler.RouteAsync", values.Name);
Assert.True(values.ActionSelected); Assert.True(values.ActionSelected);
@ -69,11 +69,11 @@ namespace Microsoft.AspNet.Mvc
// Assert // Assert
var scope = Assert.Single(sink.Scopes); var scope = Assert.Single(sink.Scopes);
Assert.Equal(typeof(MvcRouteHandler).FullName, scope.LoggerName); Assert.Equal(typeof(MvcRouteHandler).FullName, scope.LoggerName);
Assert.Equal("MvcRouteHandler.RouteAsync", scope.Scope); Assert.Equal("MvcRouteHandler.RouteAsync", scope.Scope.ToString());
var write = Assert.Single(sink.Writes); var write = Assert.Single(sink.Writes);
Assert.Equal(typeof(MvcRouteHandler).FullName, write.LoggerName); Assert.Equal(typeof(MvcRouteHandler).FullName, write.LoggerName);
Assert.Equal("MvcRouteHandler.RouteAsync", write.Scope); Assert.Equal("MvcRouteHandler.RouteAsync", write.Scope.ToString());
var values = Assert.IsType<MvcRouteHandlerRouteAsyncValues>(write.State); var values = Assert.IsType<MvcRouteHandlerRouteAsyncValues>(write.State);
Assert.Equal("MvcRouteHandler.RouteAsync", values.Name); Assert.Equal("MvcRouteHandler.RouteAsync", values.Name);
Assert.False(values.ActionSelected); Assert.False(values.ActionSelected);
@ -105,13 +105,13 @@ namespace Microsoft.AspNet.Mvc
// Assert // Assert
var scope = Assert.Single(sink.Scopes); var scope = Assert.Single(sink.Scopes);
Assert.Equal(typeof(MvcRouteHandler).FullName, scope.LoggerName); Assert.Equal(typeof(MvcRouteHandler).FullName, scope.LoggerName);
Assert.Equal("MvcRouteHandler.RouteAsync", scope.Scope); Assert.Equal("MvcRouteHandler.RouteAsync", scope.Scope.ToString());
Assert.Equal(1, sink.Writes.Count); Assert.Equal(1, sink.Writes.Count);
var write = sink.Writes[0]; var write = sink.Writes[0];
Assert.Equal(typeof(MvcRouteHandler).FullName, write.LoggerName); Assert.Equal(typeof(MvcRouteHandler).FullName, write.LoggerName);
Assert.Equal("MvcRouteHandler.RouteAsync", write.Scope); Assert.Equal("MvcRouteHandler.RouteAsync", write.Scope.ToString());
var values = Assert.IsType<MvcRouteHandlerRouteAsyncValues>(write.State); var values = Assert.IsType<MvcRouteHandlerRouteAsyncValues>(write.State);
Assert.Equal("MvcRouteHandler.RouteAsync", values.Name); Assert.Equal("MvcRouteHandler.RouteAsync", values.Name);
Assert.True(values.ActionSelected); Assert.True(values.ActionSelected);

View File

@ -926,13 +926,13 @@ namespace Microsoft.AspNet.Mvc.Routing
Assert.Equal(1, sink.Scopes.Count); Assert.Equal(1, sink.Scopes.Count);
var scope = sink.Scopes[0]; var scope = sink.Scopes[0];
Assert.Equal(typeof(AttributeRoute).FullName, scope.LoggerName); Assert.Equal(typeof(AttributeRoute).FullName, scope.LoggerName);
Assert.Equal("AttributeRoute.RouteAsync", scope.Scope); Assert.Equal("AttributeRoute.RouteAsync", scope.Scope.ToString());
Assert.Equal(1, sink.Writes.Count); Assert.Equal(1, sink.Writes.Count);
var write = sink.Writes[0]; var write = sink.Writes[0];
Assert.Equal(typeof(AttributeRoute).FullName, write.LoggerName); Assert.Equal(typeof(AttributeRoute).FullName, write.LoggerName);
Assert.Equal("AttributeRoute.RouteAsync", write.Scope); Assert.Equal("AttributeRoute.RouteAsync", write.Scope.ToString());
var values = Assert.IsType<AttributeRouteRouteAsyncValues>(write.State); var values = Assert.IsType<AttributeRouteRouteAsyncValues>(write.State);
Assert.Equal("AttributeRoute.RouteAsync", values.Name); Assert.Equal("AttributeRoute.RouteAsync", values.Name);
Assert.True(values.Handled); Assert.True(values.Handled);
@ -957,13 +957,13 @@ namespace Microsoft.AspNet.Mvc.Routing
Assert.Equal(1, sink.Scopes.Count); Assert.Equal(1, sink.Scopes.Count);
var scope = sink.Scopes[0]; var scope = sink.Scopes[0];
Assert.Equal(typeof(AttributeRoute).FullName, scope.LoggerName); Assert.Equal(typeof(AttributeRoute).FullName, scope.LoggerName);
Assert.Equal("AttributeRoute.RouteAsync", scope.Scope); Assert.Equal("AttributeRoute.RouteAsync", scope.Scope.ToString());
Assert.Equal(1, sink.Writes.Count); Assert.Equal(1, sink.Writes.Count);
var write = sink.Writes[0]; var write = sink.Writes[0];
Assert.Equal(typeof(AttributeRoute).FullName, write.LoggerName); Assert.Equal(typeof(AttributeRoute).FullName, write.LoggerName);
Assert.Equal("AttributeRoute.RouteAsync", write.Scope); Assert.Equal("AttributeRoute.RouteAsync", write.Scope.ToString());
var values = Assert.IsType<AttributeRouteRouteAsyncValues>(write.State); var values = Assert.IsType<AttributeRouteRouteAsyncValues>(write.State);
Assert.Equal("AttributeRoute.RouteAsync", values.Name); Assert.Equal("AttributeRoute.RouteAsync", values.Name);
Assert.False(values.Handled); Assert.False(values.Handled);

View File

@ -75,6 +75,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Assert // Assert
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
var logs = await GetLogsAsync(client, requestTraceId); var logs = await GetLogsAsync(client, requestTraceId);
var scopeNode = logs.FindScope(nameof(MvcRouteHandler) + ".RouteAsync"); var scopeNode = logs.FindScope(nameof(MvcRouteHandler) + ".RouteAsync");

View File

@ -82,7 +82,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
return false; return false;
} }
public IDisposable BeginScope(object scope) public IDisposable BeginScopeImpl(object scope)
{ {
return new TestDisposable(); return new TestDisposable();
} }

View File

@ -367,7 +367,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
Assert.Equal(LogLevel.Verbose, logger.Logged[1].LogLevel); Assert.Equal(LogLevel.Verbose, logger.Logged[1].LogLevel);
Assert.IsAssignableFrom<ILogValues>(logger.Logged[1].State); Assert.IsAssignableFrom<ILogValues>(logger.Logged[1].State);
Assert.StartsWith("Skipping processing for Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper", Assert.StartsWith("Skipping processing for Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper",
((ILogValues)logger.Logged[1].State).Format()); ((ILogValues)logger.Logged[1].State).ToString());
} }
[Fact] [Fact]
@ -422,7 +422,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
Assert.Equal(LogLevel.Verbose, logger.Logged[0].LogLevel); Assert.Equal(LogLevel.Verbose, logger.Logged[0].LogLevel);
Assert.IsAssignableFrom<ILogValues>(logger.Logged[0].State); Assert.IsAssignableFrom<ILogValues>(logger.Logged[0].State);
Assert.StartsWith("Skipping processing for Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper", Assert.StartsWith("Skipping processing for Microsoft.AspNet.Mvc.TagHelpers.ScriptTagHelper",
((ILogValues)logger.Logged[0].State).Format()); ((ILogValues)logger.Logged[0].State).ToString());
} }
[Fact] [Fact]

View File

@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
{ {
public List<LoggerData> Logged { get; } = new List<LoggerData>(); public List<LoggerData> Logged { get; } = new List<LoggerData>();
public IDisposable BeginScope(object state) public IDisposable BeginScopeImpl(object state)
{ {
return null; return null;
} }

View File

@ -97,7 +97,7 @@ namespace LoggingWebSite
private void CopyScopeNodeTree(ScopeNode root, ScopeNodeDto rootDto) private void CopyScopeNodeTree(ScopeNode root, ScopeNodeDto rootDto)
{ {
rootDto.LoggerName = root.Name; rootDto.LoggerName = root.Name;
rootDto.State = root.State; rootDto.State = root.State?.ToString();
rootDto.StateType = root.State?.GetType(); rootDto.StateType = root.State?.GetType();
foreach (var logInfo in root.Messages) foreach (var logInfo in root.Messages)