Created
November 21, 2015 13:47
-
-
Save dimitrispaxinos/1cc0c39254ff77530bc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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