Skip to content

Instantly share code, notes, and snippets.

@dimitrispaxinos
Created November 21, 2015 13:47
Show Gist options
  • Save dimitrispaxinos/1cc0c39254ff77530bc5 to your computer and use it in GitHub Desktop.
Save dimitrispaxinos/1cc0c39254ff77530bc5 to your computer and use it in GitHub Desktop.
/// <summary>
/// Implements the log logic of the Wrapper
/// </summary>
/// <param name="requestUri">Uri of the REST call</param>
/// <param name="responseMessage">Response Message</param>
/// <param name="restAction">Rest Action Name (GET,PUT,POST,DELETE)</param>
/// <param name="sentHttpContent">Sent HttpContent</param>
protected virtual void LogResponseMessage(Uri requestUri, HttpResponseMessage responseMessage, string restAction, HttpContent sentHttpContent = null)
{
using (LogContext.PushProperty("Request", sentHttpContent))
using (LogContext.PushProperty("Response", responseMessage.Content.ReadAsStringAsync().Result))
{
if (responseMessage.IsSuccessStatusCode)
{
_logger.Information(_templateString, restAction,
CombineAddress(requestUri),
responseMessage.StatusCode);
}
else
_logger.Error(_templateString, restAction,
CombineAddress(requestUri),
responseMessage.StatusCode);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment