Improve response status logging

This commit is contained in:
James Newton-King 2018-04-16 09:38:47 +12:00
parent aec323d8d2
commit fbb13c4c1f
No known key found for this signature in database
GPG Key ID: 0A66B2F456BF5526
2 changed files with 3 additions and 5 deletions

View File

@ -43,8 +43,8 @@ namespace Microsoft.AspNetCore.Http.Connections.Client.Internal
private static readonly Action<ILogger, HttpMethod, Uri, Exception> _sendingHttpRequest =
LoggerMessage.Define<HttpMethod, Uri>(LogLevel.Trace, new EventId(1, "SendingHttpRequest"), "Sending HTTP request {RequestMethod} '{RequestUrl}'.");
private static readonly Action<ILogger, HttpStatusCode, HttpMethod, Uri, Exception> _unsuccessfulHttpResponse =
LoggerMessage.Define<HttpStatusCode, HttpMethod, Uri>(LogLevel.Warning, new EventId(2, "UnsuccessfulHttpResponse"), "Unsuccessful HTTP response status code of {StatusCode} return from {RequestMethod} '{RequestUrl}'.");
private static readonly Action<ILogger, int, HttpMethod, Uri, Exception> _unsuccessfulHttpResponse =
LoggerMessage.Define<int, HttpMethod, Uri>(LogLevel.Warning, new EventId(2, "UnsuccessfulHttpResponse"), "Unsuccessful HTTP response {StatusCode} return from {RequestMethod} '{RequestUrl}'.");
public static void SendingHttpRequest(ILogger logger, HttpMethod requestMethod, Uri requestUrl)
{
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Client.Internal
}
public static void UnsuccessfulHttpResponse(ILogger logger, HttpStatusCode statusCode, HttpMethod requestMethod, Uri requestUrl)
{
_unsuccessfulHttpResponse(logger, statusCode, requestMethod, requestUrl, null);
_unsuccessfulHttpResponse(logger, (int)statusCode, requestMethod, requestUrl, null);
}
}
}

View File

@ -5,14 +5,12 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Connections;
using Microsoft.AspNetCore.Http.Connections.Client;
using Microsoft.AspNetCore.SignalR.Internal;
using Microsoft.AspNetCore.SignalR.Protocol;
using Microsoft.AspNetCore.SignalR.Tests;
using Microsoft.AspNetCore.Testing.xunit;