React to Logging API changes
This commit is contained in:
parent
a837854f4b
commit
4e5c99fabc
|
|
@ -19,8 +19,8 @@ namespace Microsoft.AspNetCore.Diagnostics.Elm
|
|||
_store = store;
|
||||
}
|
||||
|
||||
public void Log(LogLevel logLevel, int eventId, object state, Exception exception,
|
||||
Func<object, Exception, string> formatter)
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception,
|
||||
Func<TState, Exception, string> formatter)
|
||||
{
|
||||
if (!IsEnabled(logLevel) || (state == null && exception == null))
|
||||
{
|
||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Diagnostics.Elm
|
|||
{
|
||||
ActivityContext = GetCurrentActivityContext(),
|
||||
Name = _name,
|
||||
EventID = eventId,
|
||||
EventID = eventId.Id,
|
||||
Severity = logLevel,
|
||||
Exception = exception,
|
||||
State = state,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
|
|||
#endif
|
||||
}
|
||||
|
||||
public virtual void Log(LogLevel logLevel, int eventId, [CanBeNull] object state, [CanBeNull] Exception exception, [CanBeNull] Func<object, Exception, string> formatter)
|
||||
public virtual void Log<TState>(LogLevel logLevel, EventId eventId, [CanBeNull] TState state, [CanBeNull] Exception exception, [CanBeNull] Func<TState, Exception, string> formatter)
|
||||
{
|
||||
var errorState = state as DatabaseErrorLogState;
|
||||
if (errorState != null && exception != null && LastError != null)
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(Strings.DatabaseErrorPageMiddleware_Exception, e);
|
||||
_logger.LogError(0, e, Strings.DatabaseErrorPageMiddleware_Exception);
|
||||
}
|
||||
|
||||
throw;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("An unhandled exception has occurred while executing the request", ex);
|
||||
_logger.LogError(0, ex, "An unhandled exception has occurred while executing the request");
|
||||
|
||||
if (context.Response.HasStarted)
|
||||
{
|
||||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
catch (Exception ex2)
|
||||
{
|
||||
// If there's a Exception while generating the error page, re-throw the original exception.
|
||||
_logger.LogError("An exception was thrown attempting to display the error page.", ex2);
|
||||
_logger.LogError(0, ex2, "An exception was thrown attempting to display the error page.");
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("An unhandled exception has occurred: " + ex.Message, ex);
|
||||
_logger.LogError(0, ex, "An unhandled exception has occurred: " + ex.Message);
|
||||
// We can't do anything if the response has already started, just abort.
|
||||
if (context.Response.HasStarted)
|
||||
{
|
||||
|
|
@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
catch (Exception ex2)
|
||||
{
|
||||
// Suppress secondary exceptions, re-throw the original.
|
||||
_logger.LogError("An exception was thrown attempting to execute the error handler.", ex2);
|
||||
_logger.LogError(0, ex2, "An exception was thrown attempting to execute the error handler.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests.H
|
|||
get { return _messages; }
|
||||
}
|
||||
|
||||
public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
_messages.Add(formatter(state, exception));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Diagnostics.Tests
|
|||
var store = t.Item2;
|
||||
|
||||
// Act
|
||||
logger.Log(LogLevel.Information, 0, null, null, null);
|
||||
logger.Log<object>(LogLevel.Information, 0, null, null, null);
|
||||
|
||||
// Assert
|
||||
Assert.Empty(store.GetActivities());
|
||||
|
|
|
|||
Loading…
Reference in New Issue