Missed some logging API
This commit is contained in:
parent
4887a77498
commit
00a1127676
|
|
@ -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<object, Exception, string> formatter)
|
||||
public virtual void Log(LogLevel logLevel, int eventId, [CanBeNull] object state, [CanBeNull] Exception exception, [CanBeNull] Func<object, Exception, string> formatter)
|
||||
{
|
||||
var errorState = state as DataStoreErrorLogState;
|
||||
if (errorState != null && exception != null && LastError != null)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
_next = next;
|
||||
_serviceProvider = serviceProvider;
|
||||
_options = options;
|
||||
_logger = loggerFactory.Create<DatabaseErrorPageMiddleware>();
|
||||
_logger = loggerFactory.CreateLogger<DatabaseErrorPageMiddleware>();
|
||||
|
||||
_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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
|
||||
_next = next;
|
||||
_serviceProvider = serviceProvider;
|
||||
_logger = loggerFactory.Create<MigrationsEndPointMiddleware>();
|
||||
_logger = loggerFactory.CreateLogger<MigrationsEndPointMiddleware>();
|
||||
_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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
{
|
||||
_next = next;
|
||||
_options = options;
|
||||
_logger = loggerFactory.Create<ErrorHandlerMiddleware>();
|
||||
_logger = loggerFactory.CreateLogger<ErrorHandlerMiddleware>();
|
||||
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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<object, Exception, string> formatter)
|
||||
public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
{
|
||||
_messages.Add(formatter(state, exception));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue