diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DataStoreErrorLogger.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DataStoreErrorLogger.cs index 32d710770a..648d7889d1 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/DataStoreErrorLogger.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/DataStoreErrorLogger.cs @@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity #endif } - public virtual void Write(LogLevel logLevel, int eventId, [CanBeNull] object state, [CanBeNull] Exception exception, [CanBeNull] Func formatter) + public virtual void Log(LogLevel logLevel, int eventId, [CanBeNull] object state, [CanBeNull] Exception exception, [CanBeNull] Func formatter) { var errorState = state as DataStoreErrorLogState; if (errorState != null && exception != null && LastError != null) diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DataStoreErrorLoggerProvider.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DataStoreErrorLoggerProvider.cs index d36f4a878c..c8abe908fc 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/DataStoreErrorLoggerProvider.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/DataStoreErrorLoggerProvider.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity { private readonly DataStoreErrorLogger _logger = new DataStoreErrorLogger(); - public virtual ILogger Create(string name) + public virtual ILogger CreateLogger(string name) { return _logger; } diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs index e0e6c63b3b..64037b16d8 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity _next = next; _serviceProvider = serviceProvider; _options = options; - _logger = loggerFactory.Create(); + _logger = loggerFactory.CreateLogger(); _loggerProvider = new DataStoreErrorLoggerProvider(); loggerFactory.AddProvider(_loggerProvider); @@ -71,13 +71,13 @@ namespace Microsoft.AspNet.Diagnostics.Entity var dbContext = (DbContext)context.RequestServices.GetService(dbContextType); if (dbContext == null) { - _logger.WriteError(Strings.FormatDatabaseErrorPageMiddleware_ContextNotRegistered(dbContextType.FullName)); + _logger.LogError(Strings.FormatDatabaseErrorPageMiddleware_ContextNotRegistered(dbContextType.FullName)); } else { if (!(dbContext.Database is RelationalDatabase)) { - _logger.WriteVerbose(Strings.DatabaseErrorPage_NotRelationalDatabase); + _logger.LogVerbose(Strings.DatabaseErrorPage_NotRelationalDatabase); } else { @@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity } catch (Exception e) { - _logger.WriteError(Strings.DatabaseErrorPageMiddleware_Exception, e); + _logger.LogError(Strings.DatabaseErrorPageMiddleware_Exception, e); } throw; @@ -112,11 +112,11 @@ namespace Microsoft.AspNet.Diagnostics.Entity private static bool ShouldDisplayErrorPage(DataStoreErrorLogger.DataStoreErrorLog lastError, Exception exception, ILogger logger) { - logger.WriteVerbose(Strings.FormatDatabaseErrorPage_AttemptingToMatchException(exception.GetType())); + logger.LogVerbose(Strings.FormatDatabaseErrorPage_AttemptingToMatchException(exception.GetType())); if (!lastError.IsErrorLogged) { - logger.WriteVerbose(Strings.DatabaseErrorPage_NoRecordedException); + logger.LogVerbose(Strings.DatabaseErrorPage_NoRecordedException); return false; } @@ -128,11 +128,11 @@ namespace Microsoft.AspNet.Diagnostics.Entity if (!match) { - logger.WriteVerbose(Strings.DatabaseErrorPage_NoMatch); + logger.LogVerbose(Strings.DatabaseErrorPage_NoMatch); return false; } - logger.WriteVerbose(Strings.DatabaseErrorPage_Matched); + logger.LogVerbose(Strings.DatabaseErrorPage_Matched); return true; } } diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs index b52b130899..710aa8100d 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs @@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity _next = next; _serviceProvider = serviceProvider; - _logger = loggerFactory.Create(); + _logger = loggerFactory.CreateLogger(); _options = options; } @@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity if (context.Request.Path.Equals(_options.Path)) { - _logger.WriteVerbose(Strings.FormatMigrationsEndPointMiddleware_RequestPathMatched(context.Request.Path)); + _logger.LogVerbose(Strings.FormatMigrationsEndPointMiddleware_RequestPathMatched(context.Request.Path)); using (RequestServicesContainer.EnsureRequestServices(context, _serviceProvider)) { @@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity { try { - _logger.WriteVerbose(Strings.FormatMigrationsEndPointMiddleware_ApplyingMigrations(db.GetType().FullName)); + _logger.LogVerbose(Strings.FormatMigrationsEndPointMiddleware_ApplyingMigrations(db.GetType().FullName)); db.Database.AsRelational().ApplyMigrations(); @@ -59,12 +59,12 @@ namespace Microsoft.AspNet.Diagnostics.Entity context.Response.Headers.Add("Pragma", new[] { "no-cache" }); context.Response.Headers.Add("Cache-Control", new[] { "no-cache" }); - _logger.WriteVerbose(Strings.FormatMigrationsEndPointMiddleware_Applied(db.GetType().FullName)); + _logger.LogVerbose(Strings.FormatMigrationsEndPointMiddleware_Applied(db.GetType().FullName)); } catch (Exception ex) { var message = Strings.FormatMigrationsEndPointMiddleware_Exception(db.GetType().FullName); - _logger.WriteError(message); + _logger.LogError(message); throw new InvalidOperationException(message, ex); } } @@ -82,7 +82,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity var contextTypeName = form["context"]; if (string.IsNullOrWhiteSpace(contextTypeName)) { - logger.WriteError(Strings.MigrationsEndPointMiddleware_NoContextType); + logger.LogError(Strings.MigrationsEndPointMiddleware_NoContextType); await WriteErrorToResponse(context.Response, Strings.MigrationsEndPointMiddleware_NoContextType).WithCurrentCulture(); return null; } @@ -91,7 +91,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity if (contextType == null) { var message = Strings.FormatMigrationsEndPointMiddleware_InvalidContextType(contextTypeName); - logger.WriteError(message); + logger.LogError(message); await WriteErrorToResponse(context.Response, message).WithCurrentCulture(); return null; } @@ -100,7 +100,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity if (db == null) { var message = Strings.FormatMigrationsEndPointMiddleware_ContextNotRegistered(contextType.FullName); - logger.WriteError(message); + logger.LogError(message); await WriteErrorToResponse(context.Response, message).WithCurrentCulture(); return null; } diff --git a/src/Microsoft.AspNet.Diagnostics/ErrorHandlerMiddleware.cs b/src/Microsoft.AspNet.Diagnostics/ErrorHandlerMiddleware.cs index ab6790aadf..f34163bca1 100644 --- a/src/Microsoft.AspNet.Diagnostics/ErrorHandlerMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics/ErrorHandlerMiddleware.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Diagnostics { _next = next; _options = options; - _logger = loggerFactory.Create(); + _logger = loggerFactory.CreateLogger(); if (_options.ErrorHandler == null) { _options.ErrorHandler = _next; @@ -36,11 +36,11 @@ namespace Microsoft.AspNet.Diagnostics } catch (Exception ex) { - _logger.WriteError("An unhandled exception has occurred: " + ex.Message, ex); + _logger.LogError("An unhandled exception has occurred: " + ex.Message, ex); // We can't do anything if the response has already started, just abort. if (responseStarted) { - _logger.WriteWarning("The response has already started, the error handler will not be executed."); + _logger.LogWarning("The response has already started, the error handler will not be executed."); throw; } @@ -66,7 +66,7 @@ namespace Microsoft.AspNet.Diagnostics catch (Exception ex2) { // Suppress secondary exceptions, re-throw the original. - _logger.WriteError("An exception was thrown attempting to execute the error handler.", ex2); + _logger.LogError("An exception was thrown attempting to execute the error handler.", ex2); } finally { diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/Helpers/TestLoggerProvider.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/Helpers/TestLoggerProvider.cs index 9dfe936776..19c7e42cf5 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/Helpers/TestLoggerProvider.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/Helpers/TestLoggerProvider.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Helpers get { return _logger; } } - public ILogger Create(string name) + public ILogger CreateLogger(string name) { return _logger; } @@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Helpers get { return _messages; } } - 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) { _messages.Add(formatter(state, exception)); }