refactor: Add request/response body to debug logs

pull/92/head
Robert Dailey 2 years ago
parent 87f028978d
commit 0d71e341d5

@ -14,13 +14,25 @@ public static class FlurlLogging
{
var url = urlInterceptor(call.Request.Url.Clone());
log.Debug("HTTP Request: {Method} {Url}", call.HttpRequestMessage.Method, url);
var body = call.RequestBody;
if (body is not null)
{
log.Debug("HTTP Body:\n{Body}", body);
}
};
settings.AfterCall = call =>
settings.AfterCallAsync = async call =>
{
var statusCode = call.Response?.StatusCode.ToString() ?? "(No response)";
var url = urlInterceptor(call.Request.Url.Clone());
log.Debug("HTTP Response: {Status} {Method} {Url}", statusCode, call.HttpRequestMessage.Method, url);
var content = call.Response?.ResponseMessage.Content;
if (content is not null)
{
log.Debug("HTTP Body:\n{Body}", await content.ReadAsStringAsync());
}
};
settings.OnRedirect = call =>

Loading…
Cancel
Save