mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Add verbose HTTP logging (2.4.0 backport)
This commit is contained in:
parent
cec5c58e7c
commit
69dc4f1c16
@ -46,11 +46,12 @@ namespace Bloxstrap
|
||||
public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
||||
|
||||
// singletons
|
||||
public static readonly Logger Logger = new();
|
||||
public static readonly JsonManager<Settings> Settings = new();
|
||||
public static readonly JsonManager<State> State = new();
|
||||
public static readonly FastFlagManager FastFlags = new();
|
||||
public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All });
|
||||
|
||||
public static readonly Logger Logger = new();
|
||||
public static readonly HttpClient HttpClient = new(new HttpClientLoggingHandler(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }));
|
||||
|
||||
public static System.Windows.Forms.NotifyIcon Notification { get; private set; } = null!;
|
||||
|
||||
|
31
Bloxstrap/HttpClientLoggingHandler.cs
Normal file
31
Bloxstrap/HttpClientLoggingHandler.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bloxstrap
|
||||
{
|
||||
internal class HttpClientLoggingHandler : MessageProcessingHandler
|
||||
{
|
||||
public HttpClientLoggingHandler(HttpMessageHandler innerHandler)
|
||||
: base(innerHandler)
|
||||
{
|
||||
}
|
||||
|
||||
protected override HttpRequestMessage ProcessRequest(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
App.Logger.WriteLine($"[HttpClientLoggingHandler::HttpRequestMessage] {request.Method} {request.RequestUri}");
|
||||
return request;
|
||||
}
|
||||
|
||||
protected override HttpResponseMessage ProcessResponse(HttpResponseMessage response, CancellationToken cancellationToken)
|
||||
{
|
||||
App.Logger.WriteLine($"[HttpClientLoggingHandler::HttpResponseMessage] {(int)response.StatusCode} {response.ReasonPhrase} {response.RequestMessage!.RequestUri}");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
@ -110,8 +110,6 @@ namespace Bloxstrap
|
||||
throw new Exception($"Could not get latest deploy for channel {channel}! (HTTP {deployInfoResponse.StatusCode})");
|
||||
}
|
||||
|
||||
App.Logger.WriteLine($"[RobloxDeployment::GetInfo] Got JSON: {rawResponse}");
|
||||
|
||||
ClientVersion clientVersion = JsonSerializer.Deserialize<ClientVersion>(rawResponse)!;
|
||||
|
||||
// for preferences
|
||||
|
@ -49,14 +49,12 @@ namespace Bloxstrap
|
||||
{
|
||||
try
|
||||
{
|
||||
App.Logger.WriteLine($"[Utilities::GetJson<{typeof(T).Name}>] Getting JSON from {url}!");
|
||||
string json = await App.HttpClient.GetStringAsync(url);
|
||||
App.Logger.WriteLine($"[Utilities::GetJson<{typeof(T).Name}>] Got JSON: {json}");
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.Logger.WriteLine($"[Utilities::GetJson<{typeof(T).Name}>] Failed to deserialize JSON!");
|
||||
App.Logger.WriteLine($"[Utilities::GetJson<{typeof(T).Name}>] Failed to deserialize JSON for {url}!");
|
||||
App.Logger.WriteLine($"[Utilities::GetJson<{typeof(T).Name}>] {ex}");
|
||||
return default;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user