React to Logging API changes

This commit is contained in:
Brennan 2016-01-21 09:42:17 -08:00
parent a837854f4b
commit 4e5c99fabc
7 changed files with 11 additions and 11 deletions

View File

@ -19,8 +19,8 @@ namespace Microsoft.AspNetCore.Diagnostics.Elm
_store = store; _store = store;
} }
public void Log(LogLevel logLevel, int eventId, object state, Exception exception, public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception,
Func<object, Exception, string> formatter) Func<TState, Exception, string> formatter)
{ {
if (!IsEnabled(logLevel) || (state == null && exception == null)) if (!IsEnabled(logLevel) || (state == null && exception == null))
{ {
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Diagnostics.Elm
{ {
ActivityContext = GetCurrentActivityContext(), ActivityContext = GetCurrentActivityContext(),
Name = _name, Name = _name,
EventID = eventId, EventID = eventId.Id,
Severity = logLevel, Severity = logLevel,
Exception = exception, Exception = exception,
State = state, State = state,

View File

@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
#endif #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; var errorState = state as DatabaseErrorLogState;
if (errorState != null && exception != null && LastError != null) if (errorState != null && exception != null && LastError != null)

View File

@ -132,7 +132,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
} }
catch (Exception e) catch (Exception e)
{ {
_logger.LogError(Strings.DatabaseErrorPageMiddleware_Exception, e); _logger.LogError(0, e, Strings.DatabaseErrorPageMiddleware_Exception);
} }
throw; throw;

View File

@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Diagnostics
} }
catch (Exception ex) 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) if (context.Response.HasStarted)
{ {
@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.Diagnostics
catch (Exception ex2) catch (Exception ex2)
{ {
// If there's a Exception while generating the error page, re-throw the original exception. // 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; throw;
} }

View File

@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Diagnostics
} }
catch (Exception ex) 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. // We can't do anything if the response has already started, just abort.
if (context.Response.HasStarted) if (context.Response.HasStarted)
{ {
@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Diagnostics
catch (Exception ex2) catch (Exception ex2)
{ {
// Suppress secondary exceptions, re-throw the original. // 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 finally
{ {

View File

@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests.H
get { return _messages; } 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)); _messages.Add(formatter(state, exception));
} }

View File

@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Diagnostics.Tests
var store = t.Item2; var store = t.Item2;
// Act // Act
logger.Log(LogLevel.Information, 0, null, null, null); logger.Log<object>(LogLevel.Information, 0, null, null, null);
// Assert // Assert
Assert.Empty(store.GetActivities()); Assert.Empty(store.GetActivities());