React to Logging API changes

This commit is contained in:
Brennan 2016-01-21 09:52:39 -08:00
parent a2fe59fb2c
commit 15ed03eb26
19 changed files with 29 additions and 29 deletions

View File

@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Filter
{ {
if (copyAsyncTask.IsFaulted) if (copyAsyncTask.IsFaulted)
{ {
_log.LogError("FilteredStreamAdapter.CopyToAsync", copyAsyncTask.Exception); _log.LogError(0, copyAsyncTask.Exception, "FilteredStreamAdapter.CopyToAsync");
} }
else if (copyAsyncTask.IsCanceled) else if (copyAsyncTask.IsCanceled)
{ {
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Filter
} }
catch (Exception ex) catch (Exception ex)
{ {
_log.LogError("FilteredStreamAdapter.OnStreamClose", ex); _log.LogError(0, ex, "FilteredStreamAdapter.OnStreamClose");
} }
} }
} }

View File

@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
if (task.IsFaulted) if (task.IsFaulted)
{ {
connection.Log.LogError("ConnectionFilter.OnConnection", task.Exception); connection.Log.LogError(0, task.Exception, "ConnectionFilter.OnConnection");
connection.ConnectionControl.End(ProduceEndType.SocketDisconnect); connection.ConnectionControl.End(ProduceEndType.SocketDisconnect);
} }
else if (task.IsCanceled) else if (task.IsCanceled)
@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.LogError("ConnectionFilter.OnConnection", ex); Log.LogError(0, ex, "ConnectionFilter.OnConnection");
ConnectionControl.End(ProduceEndType.SocketDisconnect); ConnectionControl.End(ProduceEndType.SocketDisconnect);
} }
} }

View File

@ -302,7 +302,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.LogError("Abort", ex); Log.LogError(0, ex, "Abort");
} }
try try
@ -311,7 +311,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.LogError("Abort", ex); Log.LogError(0, ex, "Abort");
} }
_abortedCts = null; _abortedCts = null;
} }

View File

@ -140,7 +140,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.LogWarning("Connection processing ended abnormally", ex); Log.LogWarning(0, ex, "Connection processing ended abnormally");
} }
finally finally
{ {
@ -163,7 +163,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.LogWarning("Connection shutdown abnormally", ex); Log.LogWarning(0, ex, "Connection shutdown abnormally");
} }
} }
} }

View File

@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
var listener = (Listener) state; var listener = (Listener) state;
if (error != null) if (error != null)
{ {
listener.Log.LogError("Listener.ConnectionCallback ", error); listener.Log.LogError(0, error, "Listener.ConnectionCallback");
} }
else else
{ {

View File

@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
catch (UvException ex) catch (UvException ex)
{ {
dispatchPipe.Dispose(); dispatchPipe.Dispose();
Log.LogError("ListenerPrimary.OnListenPipe", ex); Log.LogError(0, ex, "ListenerPrimary.OnListenPipe");
return; return;
} }

View File

@ -112,7 +112,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
{ {
Exception ex; Exception ex;
Thread.Loop.Libuv.Check(status, out ex); Thread.Loop.Libuv.Check(status, out ex);
Log.LogError("DispatchPipe.ReadStart", ex); Log.LogError(0, ex, "DispatchPipe.ReadStart");
} }
DispatchPipe.Dispose(); DispatchPipe.Dispose();
@ -132,7 +132,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (UvException ex) catch (UvException ex)
{ {
Log.LogError("DispatchPipe.Accept", ex); Log.LogError(0, ex, "DispatchPipe.Accept");
acceptSocket.Dispose(); acceptSocket.Dispose();
return; return;
} }

View File

@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (UvException ex) catch (UvException ex)
{ {
Log.LogError("PipeListener.OnConnection", ex); Log.LogError(0, ex, "PipeListener.OnConnection");
acceptSocket.Dispose(); acceptSocket.Dispose();
return; return;
} }

View File

@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (UvException ex) catch (UvException ex)
{ {
Log.LogError("ListenerPrimary.OnConnection", ex); Log.LogError(0, ex, "ListenerPrimary.OnConnection");
acceptSocket.Dispose(); acceptSocket.Dispose();
return; return;
} }

View File

@ -653,7 +653,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (Exception ex) catch (Exception ex)
{ {
Self._log.LogError("SocketOutput.OnWriteCompleted", ex); Self._log.LogError(0, ex, "SocketOutput.OnWriteCompleted");
} }
} }
} }

View File

@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (UvException ex) catch (UvException ex)
{ {
Log.LogError("TcpListener.OnConnection", ex); Log.LogError(0, ex, "TcpListener.OnConnection");
acceptSocket.Dispose(); acceptSocket.Dispose();
return; return;
} }

View File

@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
} }
catch (UvException ex) catch (UvException ex)
{ {
Log.LogError("TcpListenerPrimary.OnConnection", ex); Log.LogError(0, ex, "TcpListenerPrimary.OnConnection");
acceptSocket.Dispose(); acceptSocket.Dispose();
return; return;
} }

View File

@ -333,7 +333,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel
} }
else else
{ {
_log.LogError("KestrelThread.DoPostWork", ex); _log.LogError(0, ex, "KestrelThread.DoPostWork");
throw; throw;
} }
} }
@ -362,7 +362,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel
} }
catch (Exception ex) catch (Exception ex)
{ {
_log.LogError("KestrelThread.DoPostCloseHandle", ex); _log.LogError(0, ex, "KestrelThread.DoPostCloseHandle");
throw; throw;
} }
} }

View File

@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel
public virtual void ApplicationError(Exception ex) public virtual void ApplicationError(Exception ex)
{ {
_logger.LogError(13, "An unhandled exception was thrown by the application.", ex); _logger.LogError(13, ex, "An unhandled exception was thrown by the application.");
} }
public virtual void ConnectionError(long connectionId, Exception ex) public virtual void ConnectionError(long connectionId, Exception ex)
@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel
_connectionDisconnectedWrite(_logger, connectionId, count, ex); _connectionDisconnectedWrite(_logger, connectionId, count, ex);
} }
public virtual void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter) public virtual void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{ {
_logger.Log(logLevel, eventId, state, exception, formatter); _logger.Log(logLevel, eventId, state, exception, formatter);
} }

View File

@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Networking
} }
catch (Exception ex) catch (Exception ex)
{ {
req._log.LogError("UvConnectRequest", ex); req._log.LogError(0, ex, "UvConnectRequest");
throw; throw;
} }
} }

View File

@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Networking
} }
catch (Exception ex) catch (Exception ex)
{ {
stream._log.LogError("UvConnectionCb", ex); stream._log.LogError(0, ex, "UvConnectionCb");
throw; throw;
} }
} }
@ -147,7 +147,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Networking
} }
catch (Exception ex) catch (Exception ex)
{ {
stream._log.LogError("UvAllocCb", ex); stream._log.LogError(0, ex, "UvAllocCb");
buf = stream.Libuv.buf_init(IntPtr.Zero, 0); buf = stream.Libuv.buf_init(IntPtr.Zero, 0);
throw; throw;
} }
@ -163,7 +163,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Networking
} }
catch (Exception ex) catch (Exception ex)
{ {
stream._log.LogError("UbReadCb", ex); stream._log.LogError(0, ex, "UbReadCb");
throw; throw;
} }
} }

View File

@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Networking
} }
catch (Exception ex) catch (Exception ex)
{ {
req._log.LogError("UvWriteCb", ex); req._log.LogError(0, ex, "UvWriteCb");
throw; throw;
} }
} }

View File

@ -1167,10 +1167,10 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
return true; return true;
} }
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)
{ {
// Application errors are logged using 13 as the eventId. // Application errors are logged using 13 as the eventId.
if (eventId == 13) if (eventId.Id == 13)
{ {
ApplicationErrorsLogged++; ApplicationErrorsLogged++;
} }

View File

@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
public class TestLogger : ILogger public class TestLogger : ILogger
{ {
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 false #if false
Console.WriteLine($"Log {logLevel}[{eventId}]: {formatter(state, exception)} {exception?.Message}"); Console.WriteLine($"Log {logLevel}[{eventId}]: {formatter(state, exception)} {exception?.Message}");