updating ILogger, see aspnet/Logging#3
This commit is contained in:
parent
3f29de5a5f
commit
0f5bbdf417
2
Mvc.sln
2
Mvc.sln
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.22013.1
|
||||
VisualStudioVersion = 14.0.22115.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}"
|
||||
EndProject
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Mvc.Logging
|
|||
public static class LogFormatter
|
||||
{
|
||||
/// <summary>
|
||||
/// A formatter for use with <see cref="Microsoft.Framework.Logging.ILogger.WriteCore(
|
||||
/// A formatter for use with <see cref="Microsoft.Framework.Logging.ILogger.Write(
|
||||
/// Framework.Logging.TraceType,
|
||||
/// int,
|
||||
/// object,
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ namespace Microsoft.AspNet.Mvc.Logging
|
|||
{
|
||||
internal static class LoggerExtensions
|
||||
{
|
||||
public static bool WriteValues([NotNull] this ILogger logger, object values)
|
||||
public static void WriteValues([NotNull] this ILogger logger, object values)
|
||||
{
|
||||
return logger.WriteCore(
|
||||
logger.Write(
|
||||
eventType: TraceType.Information,
|
||||
eventId: 0,
|
||||
state: values,
|
||||
|
|
|
|||
|
|
@ -41,15 +41,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
Assert.Equal(typeof(DefaultActionSelector).FullName, scope.LoggerName);
|
||||
Assert.Equal("DefaultActionSelector.SelectAsync", scope.Scope);
|
||||
|
||||
// There is a record for IsEnabled and one for WriteCore.
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(1, sink.Writes.Count);
|
||||
|
||||
var enabled = sink.Writes[0];
|
||||
Assert.Equal(typeof(DefaultActionSelector).FullName, enabled.LoggerName);
|
||||
Assert.Equal("DefaultActionSelector.SelectAsync", enabled.Scope);
|
||||
Assert.Null(enabled.State);
|
||||
|
||||
var write = sink.Writes[1];
|
||||
var write = sink.Writes[0];
|
||||
Assert.Equal(typeof(DefaultActionSelector).FullName, write.LoggerName);
|
||||
Assert.Equal("DefaultActionSelector.SelectAsync", write.Scope);
|
||||
var values = Assert.IsType<DefaultActionSelectorSelectAsyncValues>(write.State);
|
||||
|
|
@ -96,15 +90,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
Assert.Equal(typeof(DefaultActionSelector).FullName, scope.LoggerName);
|
||||
Assert.Equal("DefaultActionSelector.SelectAsync", scope.Scope);
|
||||
|
||||
// There is a record for IsEnabled and one for WriteCore.
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(1, sink.Writes.Count);
|
||||
|
||||
var enabled = sink.Writes[0];
|
||||
Assert.Equal(typeof(DefaultActionSelector).FullName, enabled.LoggerName);
|
||||
Assert.Equal("DefaultActionSelector.SelectAsync", enabled.Scope);
|
||||
Assert.Null(enabled.State);
|
||||
|
||||
var write = sink.Writes[1];
|
||||
var write = sink.Writes[0];
|
||||
Assert.Equal(typeof(DefaultActionSelector).FullName, write.LoggerName);
|
||||
Assert.Equal("DefaultActionSelector.SelectAsync", write.Scope);
|
||||
var values = Assert.IsType<DefaultActionSelectorSelectAsyncValues>(write.State);
|
||||
|
|
@ -144,15 +132,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
Assert.Equal(typeof(DefaultActionSelector).FullName, scope.LoggerName);
|
||||
Assert.Equal("DefaultActionSelector.SelectAsync", scope.Scope);
|
||||
|
||||
// There is a record for IsEnabled and one for WriteCore.
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(1, sink.Writes.Count);
|
||||
|
||||
var enabled = sink.Writes[0];
|
||||
Assert.Equal(typeof(DefaultActionSelector).FullName, enabled.LoggerName);
|
||||
Assert.Equal("DefaultActionSelector.SelectAsync", enabled.Scope);
|
||||
Assert.Null(enabled.State);
|
||||
|
||||
var write = sink.Writes[1];
|
||||
var write = sink.Writes[0];
|
||||
Assert.Equal(typeof(DefaultActionSelector).FullName, write.LoggerName);
|
||||
Assert.Equal("DefaultActionSelector.SelectAsync", write.Scope);
|
||||
var values = Assert.IsType<DefaultActionSelectorSelectAsyncValues>(write.State);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@ namespace Microsoft.AspNet.Mvc
|
|||
return NullDisposable.Instance;
|
||||
}
|
||||
|
||||
public bool WriteCore(TraceType eventType, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
public void Write(TraceType eventType, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsEnabled(TraceType eventType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
return NullDisposable.Instance;
|
||||
}
|
||||
|
||||
public bool WriteCore(TraceType eventType, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
public void Write(TraceType eventType, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
{
|
||||
_sink.Write(new WriteCoreContext()
|
||||
_sink.Write(new WriteContext()
|
||||
{
|
||||
EventType = eventType,
|
||||
EventId = eventId,
|
||||
|
|
@ -45,7 +45,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
LoggerName = _name,
|
||||
Scope = _scope
|
||||
});
|
||||
}
|
||||
|
||||
public bool IsEnabled(TraceType eventType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,25 +9,25 @@ namespace Microsoft.AspNet.Mvc
|
|||
public class TestSink
|
||||
{
|
||||
public TestSink(
|
||||
Func<WriteCoreContext, bool> writeEnabled = null,
|
||||
Func<WriteContext, bool> writeEnabled = null,
|
||||
Func<BeginScopeContext, bool> beginEnabled = null)
|
||||
{
|
||||
WriteEnabled = writeEnabled;
|
||||
BeginEnabled = beginEnabled;
|
||||
|
||||
Scopes = new List<BeginScopeContext>();
|
||||
Writes = new List<WriteCoreContext>();
|
||||
Writes = new List<WriteContext>();
|
||||
}
|
||||
|
||||
public Func<WriteCoreContext, bool> WriteEnabled { get; set; }
|
||||
public Func<WriteContext, bool> WriteEnabled { get; set; }
|
||||
|
||||
public Func<BeginScopeContext, bool> BeginEnabled { get; set; }
|
||||
|
||||
public List<BeginScopeContext> Scopes { get; set; }
|
||||
|
||||
public List<WriteCoreContext> Writes { get; set; }
|
||||
public List<WriteContext> Writes { get; set; }
|
||||
|
||||
public void Write(WriteCoreContext context)
|
||||
public void Write(WriteContext context)
|
||||
{
|
||||
if (WriteEnabled == null || WriteEnabled(context))
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
}
|
||||
}
|
||||
|
||||
public static bool EnableWithTypeName<T>(WriteCoreContext context)
|
||||
public static bool EnableWithTypeName<T>(WriteContext context)
|
||||
{
|
||||
return context.LoggerName.Equals(typeof(T).FullName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using Microsoft.Framework.Logging;
|
|||
|
||||
namespace Microsoft.AspNet.Mvc
|
||||
{
|
||||
public class WriteCoreContext
|
||||
public class WriteContext
|
||||
{
|
||||
public TraceType EventType { get; set; }
|
||||
|
||||
|
|
@ -38,15 +38,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
Assert.Equal(typeof(MvcRouteHandler).FullName, scope.LoggerName);
|
||||
Assert.Equal("MvcRouteHandler.RouteAsync", scope.Scope);
|
||||
|
||||
// There is a record for IsEnabled and one for WriteCore.
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(1, sink.Writes.Count);
|
||||
|
||||
var enabled = sink.Writes[0];
|
||||
Assert.Equal(typeof(MvcRouteHandler).FullName, enabled.LoggerName);
|
||||
Assert.Equal("MvcRouteHandler.RouteAsync", enabled.Scope);
|
||||
Assert.Null(enabled.State);
|
||||
|
||||
var write = sink.Writes[1];
|
||||
var write = sink.Writes[0];
|
||||
Assert.Equal(typeof(MvcRouteHandler).FullName, write.LoggerName);
|
||||
Assert.Equal("MvcRouteHandler.RouteAsync", write.Scope);
|
||||
var values = Assert.IsType<MvcRouteHandlerRouteAsyncValues>(write.State);
|
||||
|
|
@ -82,15 +76,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
Assert.Equal(typeof(MvcRouteHandler).FullName, scope.LoggerName);
|
||||
Assert.Equal("MvcRouteHandler.RouteAsync", scope.Scope);
|
||||
|
||||
// There is a record for IsEnabled and one for WriteCore.
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(1, sink.Writes.Count);
|
||||
|
||||
var enabled = sink.Writes[0];
|
||||
Assert.Equal(typeof(MvcRouteHandler).FullName, enabled.LoggerName);
|
||||
Assert.Equal("MvcRouteHandler.RouteAsync", enabled.Scope);
|
||||
Assert.Null(enabled.State);
|
||||
|
||||
var write = sink.Writes[1];
|
||||
var write = sink.Writes[0];
|
||||
Assert.Equal(typeof(MvcRouteHandler).FullName, write.LoggerName);
|
||||
Assert.Equal("MvcRouteHandler.RouteAsync", write.Scope);
|
||||
var values = Assert.IsType<MvcRouteHandlerRouteAsyncValues>(write.State);
|
||||
|
|
@ -127,15 +115,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
Assert.Equal(typeof(MvcRouteHandler).FullName, scope.LoggerName);
|
||||
Assert.Equal("MvcRouteHandler.RouteAsync", scope.Scope);
|
||||
|
||||
// There is a record for IsEnabled and one for WriteCore.
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(1, sink.Writes.Count);
|
||||
|
||||
var enabled = sink.Writes[0];
|
||||
Assert.Equal(typeof(MvcRouteHandler).FullName, enabled.LoggerName);
|
||||
Assert.Equal("MvcRouteHandler.RouteAsync", enabled.Scope);
|
||||
Assert.Null(enabled.State);
|
||||
|
||||
var write = sink.Writes[1];
|
||||
var write = sink.Writes[0];
|
||||
Assert.Equal(typeof(MvcRouteHandler).FullName, write.LoggerName);
|
||||
Assert.Equal("MvcRouteHandler.RouteAsync", write.Scope);
|
||||
var values = Assert.IsType<MvcRouteHandlerRouteAsyncValues>(write.State);
|
||||
|
|
|
|||
|
|
@ -682,15 +682,9 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
Assert.Equal(typeof(AttributeRoute).FullName, scope.LoggerName);
|
||||
Assert.Equal("AttributeRoute.RouteAsync", scope.Scope);
|
||||
|
||||
// There is a record for IsEnabled and one for WriteCore.
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(1, sink.Writes.Count);
|
||||
|
||||
var enabled = sink.Writes[0];
|
||||
Assert.Equal(typeof(AttributeRoute).FullName, enabled.LoggerName);
|
||||
Assert.Equal("AttributeRoute.RouteAsync", enabled.Scope);
|
||||
Assert.Null(enabled.State);
|
||||
|
||||
var write = sink.Writes[1];
|
||||
var write = sink.Writes[0];
|
||||
Assert.Equal(typeof(AttributeRoute).FullName, write.LoggerName);
|
||||
Assert.Equal("AttributeRoute.RouteAsync", write.Scope);
|
||||
var values = Assert.IsType<AttributeRouteRouteAsyncValues>(write.State);
|
||||
|
|
@ -719,15 +713,9 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
Assert.Equal(typeof(AttributeRoute).FullName, scope.LoggerName);
|
||||
Assert.Equal("AttributeRoute.RouteAsync", scope.Scope);
|
||||
|
||||
// There is a record for IsEnabled and one for WriteCore.
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(1, sink.Writes.Count);
|
||||
|
||||
var enabled = sink.Writes[0];
|
||||
Assert.Equal(typeof(AttributeRoute).FullName, enabled.LoggerName);
|
||||
Assert.Equal("AttributeRoute.RouteAsync", enabled.Scope);
|
||||
Assert.Null(enabled.State);
|
||||
|
||||
var write = sink.Writes[1];
|
||||
var write = sink.Writes[0];
|
||||
Assert.Equal(typeof(AttributeRoute).FullName, write.LoggerName);
|
||||
Assert.Equal("AttributeRoute.RouteAsync", write.Scope);
|
||||
var values = Assert.IsType<AttributeRouteRouteAsyncValues>(write.State);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,11 @@ namespace Microsoft.AspNet.Mvc
|
|||
return NullDisposable.Instance;
|
||||
}
|
||||
|
||||
public bool WriteCore(TraceType eventType, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
public void Write(TraceType eventType, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsEnabled(TraceType eventType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue