From 16f1ebe6a8bb0d4bbadde0475f7b9b4b06536353 Mon Sep 17 00:00:00 2001 From: Brennan Date: Wed, 4 Mar 2015 17:07:58 -0800 Subject: [PATCH 1/2] Logging API changes --- src/Microsoft.AspNet.Routing/Logging/LoggerExtensions.cs | 2 +- src/Microsoft.AspNet.Routing/RouteCollection.cs | 2 +- src/Microsoft.AspNet.Routing/RouterMiddleware.cs | 2 +- src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs | 4 ++-- test/Microsoft.AspNet.Routing.Tests/Logging/NullLogger.cs | 2 +- .../Logging/NullLoggerFactory.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Routing/Logging/LoggerExtensions.cs b/src/Microsoft.AspNet.Routing/Logging/LoggerExtensions.cs index b0bea0e851..6b9ccf2155 100644 --- a/src/Microsoft.AspNet.Routing/Logging/LoggerExtensions.cs +++ b/src/Microsoft.AspNet.Routing/Logging/LoggerExtensions.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Routing.Logging.Internal { public static void WriteValues([NotNull] this ILogger logger, object values) { - logger.Write( + logger.Log( logLevel: LogLevel.Verbose, eventId: 0, state: values, diff --git a/src/Microsoft.AspNet.Routing/RouteCollection.cs b/src/Microsoft.AspNet.Routing/RouteCollection.cs index 2a85f426de..4afb95591c 100644 --- a/src/Microsoft.AspNet.Routing/RouteCollection.cs +++ b/src/Microsoft.AspNet.Routing/RouteCollection.cs @@ -229,7 +229,7 @@ namespace Microsoft.AspNet.Routing if (_logger == null) { var factory = context.RequestServices.GetRequiredService(); - _logger = factory.Create(); + _logger = factory.CreateLogger(); } } diff --git a/src/Microsoft.AspNet.Routing/RouterMiddleware.cs b/src/Microsoft.AspNet.Routing/RouterMiddleware.cs index 46f357cbc6..545dc7491f 100644 --- a/src/Microsoft.AspNet.Routing/RouterMiddleware.cs +++ b/src/Microsoft.AspNet.Routing/RouterMiddleware.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Builder _services = services; _router = router; - _logger = loggerFactory.Create(); + _logger = loggerFactory.CreateLogger(); } public async Task Invoke(HttpContext httpContext) diff --git a/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs b/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs index 6d706061c6..d0269f55f6 100644 --- a/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs +++ b/src/Microsoft.AspNet.Routing/Template/TemplateRoute.cs @@ -363,8 +363,8 @@ namespace Microsoft.AspNet.Routing.Template if (_logger == null) { var factory = context.RequestServices.GetRequiredService(); - _logger = factory.Create(); - _constraintLogger = factory.Create(typeof(RouteConstraintMatcher).FullName); + _logger = factory.CreateLogger(); + _constraintLogger = factory.CreateLogger(typeof(RouteConstraintMatcher).FullName); } } diff --git a/test/Microsoft.AspNet.Routing.Tests/Logging/NullLogger.cs b/test/Microsoft.AspNet.Routing.Tests/Logging/NullLogger.cs index 3b2d7ad971..59b3867fd3 100644 --- a/test/Microsoft.AspNet.Routing.Tests/Logging/NullLogger.cs +++ b/test/Microsoft.AspNet.Routing.Tests/Logging/NullLogger.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Routing return NullDisposable.Instance; } - public void Write(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) + public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) { } diff --git a/test/Microsoft.AspNet.Routing.Tests/Logging/NullLoggerFactory.cs b/test/Microsoft.AspNet.Routing.Tests/Logging/NullLoggerFactory.cs index 060482c200..bf65ab225d 100644 --- a/test/Microsoft.AspNet.Routing.Tests/Logging/NullLoggerFactory.cs +++ b/test/Microsoft.AspNet.Routing.Tests/Logging/NullLoggerFactory.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Routing public static NullLoggerFactory Instance = new NullLoggerFactory(); - public ILogger Create(string name) + public ILogger CreateLogger(string name) { return NullLogger.Instance; } From ca32af61a7025d78bd63fb64e62e7b2412b09cca Mon Sep 17 00:00:00 2001 From: Brennan Date: Wed, 4 Mar 2015 17:44:23 -0800 Subject: [PATCH 2/2] Removing Null* using Testing Null* classes --- .../Logging/NullDisposable.cs | 17 ------------ .../Logging/NullLogger.cs | 27 ------------------- .../Logging/NullLoggerFactory.cs | 23 ---------------- 3 files changed, 67 deletions(-) delete mode 100644 test/Microsoft.AspNet.Routing.Tests/Logging/NullDisposable.cs delete mode 100644 test/Microsoft.AspNet.Routing.Tests/Logging/NullLogger.cs delete mode 100644 test/Microsoft.AspNet.Routing.Tests/Logging/NullLoggerFactory.cs diff --git a/test/Microsoft.AspNet.Routing.Tests/Logging/NullDisposable.cs b/test/Microsoft.AspNet.Routing.Tests/Logging/NullDisposable.cs deleted file mode 100644 index ad687d1dbe..0000000000 --- a/test/Microsoft.AspNet.Routing.Tests/Logging/NullDisposable.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.AspNet.Routing -{ - public class NullDisposable : IDisposable - { - public static NullDisposable Instance = new NullDisposable(); - - public void Dispose() - { - // intentionally does nothing - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Routing.Tests/Logging/NullLogger.cs b/test/Microsoft.AspNet.Routing.Tests/Logging/NullLogger.cs deleted file mode 100644 index 59b3867fd3..0000000000 --- a/test/Microsoft.AspNet.Routing.Tests/Logging/NullLogger.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Routing -{ - public class NullLogger : ILogger - { - public static NullLogger Instance = new NullLogger(); - - public IDisposable BeginScope(object state) - { - return NullDisposable.Instance; - } - - public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) - { - } - - public bool IsEnabled(LogLevel logLevel) - { - return false; - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Routing.Tests/Logging/NullLoggerFactory.cs b/test/Microsoft.AspNet.Routing.Tests/Logging/NullLoggerFactory.cs deleted file mode 100644 index bf65ab225d..0000000000 --- a/test/Microsoft.AspNet.Routing.Tests/Logging/NullLoggerFactory.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Routing -{ - public class NullLoggerFactory : ILoggerFactory - { - public LogLevel MinimumLevel { get; set; } - - public static NullLoggerFactory Instance = new NullLoggerFactory(); - - public ILogger CreateLogger(string name) - { - return NullLogger.Instance; - } - - public void AddProvider(ILoggerProvider provider) - { - } - } -} \ No newline at end of file