mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Add verbose HTTP logging
This commit is contained in:
parent
dc0531eb38
commit
9ea7900c05
@ -46,15 +46,15 @@ namespace Bloxstrap
|
||||
public static bool IsMenuLaunch { get; private set; } = false;
|
||||
public static string[] LaunchArgs { get; private set; } = null!;
|
||||
|
||||
public static BuildMetadataAttribute BuildMetadata => Assembly.GetExecutingAssembly().GetCustomAttribute<BuildMetadataAttribute>()!;
|
||||
public static BuildMetadataAttribute BuildMetadata = Assembly.GetExecutingAssembly().GetCustomAttribute<BuildMetadataAttribute>()!;
|
||||
public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
||||
|
||||
// singletons
|
||||
public static readonly Logger Logger = new();
|
||||
public static readonly HttpClient HttpClient = new(new HttpClientLoggingHandler(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }));
|
||||
|
||||
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 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
|
||||
|
@ -38,9 +38,9 @@
|
||||
<StackPanel Orientation="Horizontal" FlowDirection="LeftToRight" HorizontalAlignment="Right">
|
||||
<Button x:Name="LocateLogFileButton" Content="Locate log file" />
|
||||
<ComboBox x:Name="ReportOptions" SelectedIndex="0" Padding="12,6,12,6" Margin="12,0,0,0">
|
||||
<ComboBoxItem Content="Report exception" Visibility="Collapsed" />
|
||||
<ComboBoxItem Content="Report via GitHub" />
|
||||
<ComboBoxItem Content="Report via Discord" />
|
||||
<ComboBoxItem Content="Submit report..." Visibility="Collapsed" />
|
||||
<ComboBoxItem Content="Submit report via GitHub" />
|
||||
<ComboBoxItem Content="Submit report via Discord" />
|
||||
</ComboBox>
|
||||
<Button x:Name="CloseButton" MinWidth="100" Content="Close" Margin="12,0,0,0" />
|
||||
</StackPanel>
|
||||
|
@ -1,13 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Media;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
using Bloxstrap.Utility;
|
||||
|
||||
@ -60,6 +55,12 @@ namespace Bloxstrap.UI
|
||||
};
|
||||
|
||||
SystemSounds.Hand.Play();
|
||||
|
||||
Loaded += delegate
|
||||
{
|
||||
IntPtr hWnd = new WindowInteropHelper(this).Handle;
|
||||
NativeMethods.FlashWindow(hWnd, true);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -27,14 +25,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