Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

React to Logging API changes #593

Merged
merged 1 commit into from
Jan 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ private void OnStreamClose(Task copyAsyncTask)
{
if (copyAsyncTask.IsFaulted)
{
_log.LogError("FilteredStreamAdapter.CopyToAsync", copyAsyncTask.Exception);
_log.LogError(0, copyAsyncTask.Exception, "FilteredStreamAdapter.CopyToAsync");
}
else if (copyAsyncTask.IsCanceled)
{
@@ -62,7 +62,7 @@ private void OnStreamClose(Task copyAsyncTask)
}
catch (Exception ex)
{
_log.LogError("FilteredStreamAdapter.OnStreamClose", ex);
_log.LogError(0, ex, "FilteredStreamAdapter.OnStreamClose");
}
}
}
4 changes: 2 additions & 2 deletions src/Microsoft.AspNetCore.Server.Kestrel/Http/Connection.cs
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ public void Start()

if (task.IsFaulted)
{
connection.Log.LogError("ConnectionFilter.OnConnection", task.Exception);
connection.Log.LogError(0, task.Exception, "ConnectionFilter.OnConnection");
connection.ConnectionControl.End(ProduceEndType.SocketDisconnect);
}
else if (task.IsCanceled)
@@ -103,7 +103,7 @@ public void Start()
}
catch (Exception ex)
{
Log.LogError("ConnectionFilter.OnConnection", ex);
Log.LogError(0, ex, "ConnectionFilter.OnConnection");
ConnectionControl.End(ProduceEndType.SocketDisconnect);
}
}
4 changes: 2 additions & 2 deletions src/Microsoft.AspNetCore.Server.Kestrel/Http/Frame.cs
Original file line number Diff line number Diff line change
@@ -302,7 +302,7 @@ public void Abort()
}
catch (Exception ex)
{
Log.LogError("Abort", ex);
Log.LogError(0, ex, "Abort");
}

try
@@ -311,7 +311,7 @@ public void Abort()
}
catch (Exception ex)
{
Log.LogError("Abort", ex);
Log.LogError(0, ex, "Abort");
}
_abortedCts = null;
}
4 changes: 2 additions & 2 deletions src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameOfT.cs
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@ public override async Task RequestProcessingAsync()
}
catch (Exception ex)
{
Log.LogWarning("Connection processing ended abnormally", ex);
Log.LogWarning(0, ex, "Connection processing ended abnormally");
}
finally
{
@@ -163,7 +163,7 @@ public override async Task RequestProcessingAsync()
}
catch (Exception ex)
{
Log.LogWarning("Connection shutdown abnormally", ex);
Log.LogWarning(0, ex, "Connection shutdown abnormally");
}
}
}
2 changes: 1 addition & 1 deletion src/Microsoft.AspNetCore.Server.Kestrel/Http/Listener.cs
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ protected static void ConnectionCallback(UvStreamHandle stream, int status, Exce
var listener = (Listener) state;
if (error != null)
{
listener.Log.LogError("Listener.ConnectionCallback ", error);
listener.Log.LogError(0, error, "Listener.ConnectionCallback");
}
else
{
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ private void OnListenPipe(UvStreamHandle pipe, int status, Exception error)
catch (UvException ex)
{
dispatchPipe.Dispose();
Log.LogError("ListenerPrimary.OnListenPipe", ex);
Log.LogError(0, ex, "ListenerPrimary.OnListenPipe");
return;
}

Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ private void ReadStartCallback(UvStreamHandle handle, int status)
{
Exception ex;
Thread.Loop.Libuv.Check(status, out ex);
Log.LogError("DispatchPipe.ReadStart", ex);
Log.LogError(0, ex, "DispatchPipe.ReadStart");
}

DispatchPipe.Dispose();
@@ -132,7 +132,7 @@ private void ReadStartCallback(UvStreamHandle handle, int status)
}
catch (UvException ex)
{
Log.LogError("DispatchPipe.Accept", ex);
Log.LogError(0, ex, "DispatchPipe.Accept");
acceptSocket.Dispose();
return;
}
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ protected override void OnConnection(UvStreamHandle listenSocket, int status)
}
catch (UvException ex)
{
Log.LogError("PipeListener.OnConnection", ex);
Log.LogError(0, ex, "PipeListener.OnConnection");
acceptSocket.Dispose();
return;
}
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ protected override void OnConnection(UvStreamHandle listenSocket, int status)
}
catch (UvException ex)
{
Log.LogError("ListenerPrimary.OnConnection", ex);
Log.LogError(0, ex, "ListenerPrimary.OnConnection");
acceptSocket.Dispose();
return;
}
Original file line number Diff line number Diff line change
@@ -653,7 +653,7 @@ public void CompleteOnThreadPool()
}
catch (Exception ex)
{
Self._log.LogError("SocketOutput.OnWriteCompleted", ex);
Self._log.LogError(0, ex, "SocketOutput.OnWriteCompleted");
}
}
}
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ protected override void OnConnection(UvStreamHandle listenSocket, int status)
}
catch (UvException ex)
{
Log.LogError("TcpListener.OnConnection", ex);
Log.LogError(0, ex, "TcpListener.OnConnection");
acceptSocket.Dispose();
return;
}
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ protected override void OnConnection(UvStreamHandle listenSocket, int status)
}
catch (UvException ex)
{
Log.LogError("TcpListenerPrimary.OnConnection", ex);
Log.LogError(0, ex, "TcpListenerPrimary.OnConnection");
acceptSocket.Dispose();
return;
}
Original file line number Diff line number Diff line change
@@ -333,7 +333,7 @@ private bool DoPostWork()
}
else
{
_log.LogError("KestrelThread.DoPostWork", ex);
_log.LogError(0, ex, "KestrelThread.DoPostWork");
throw;
}
}
@@ -362,7 +362,7 @@ private bool DoPostCloseHandle()
}
catch (Exception ex)
{
_log.LogError("KestrelThread.DoPostCloseHandle", ex);
_log.LogError(0, ex, "KestrelThread.DoPostCloseHandle");
throw;
}
}
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ public virtual void ConnectionWriteCallback(long connectionId, int status)

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)
@@ -128,7 +128,7 @@ public virtual void ConnectionDisconnectedWrite(long connectionId, int 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);
}
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ private static void UvConnectCb(IntPtr ptr, int status)
}
catch (Exception ex)
{
req._log.LogError("UvConnectRequest", ex);
req._log.LogError(0, ex, "UvConnectRequest");
throw;
}
}
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ private static void UvConnectionCb(IntPtr handle, int status)
}
catch (Exception ex)
{
stream._log.LogError("UvConnectionCb", ex);
stream._log.LogError(0, ex, "UvConnectionCb");
throw;
}
}
@@ -147,7 +147,7 @@ private static void UvAllocCb(IntPtr handle, int suggested_size, out Libuv.uv_bu
}
catch (Exception ex)
{
stream._log.LogError("UvAllocCb", ex);
stream._log.LogError(0, ex, "UvAllocCb");
buf = stream.Libuv.buf_init(IntPtr.Zero, 0);
throw;
}
@@ -163,7 +163,7 @@ private static void UvReadCb(IntPtr handle, int status, ref Libuv.uv_buf_t buf)
}
catch (Exception ex)
{
stream._log.LogError("UbReadCb", ex);
stream._log.LogError(0, ex, "UbReadCb");
throw;
}
}
Original file line number Diff line number Diff line change
@@ -177,7 +177,7 @@ private static void UvWriteCb(IntPtr ptr, int status)
}
catch (Exception ex)
{
req._log.LogError("UvWriteCb", ex);
req._log.LogError(0, ex, "UvWriteCb");
throw;
}
}
4 changes: 2 additions & 2 deletions test/Microsoft.AspNetCore.Server.KestrelTests/EngineTests.cs
Original file line number Diff line number Diff line change
@@ -1167,10 +1167,10 @@ public bool IsEnabled(LogLevel logLevel)
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.
if (eventId == 13)
if (eventId.Id == 13)
{
ApplicationErrorsLogged++;
}
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ public override void ConnectionWriteCallback(long connectionId, int status)

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
Console.WriteLine($"Log {logLevel}[{eventId}]: {formatter(state, exception)} {exception?.Message}");