-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
979 additions
and
730 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Windows.Storage; | ||
|
||
internal class LogHelper | ||
{ | ||
public static async void ShowErrorMessageAndLog(Exception ex, XamlRoot xamlRoot) | ||
{ | ||
var errorMessage = $"Caught Error: {ex.Message}"; | ||
|
||
await LogError(errorMessage); | ||
|
||
InitiliseErrorMessage(errorMessage, xamlRoot); | ||
} | ||
|
||
private static async Task LogToFile(string message, string fileName) | ||
{ | ||
try | ||
{ | ||
var tempFolder = ApplicationData.Current.TemporaryFolder; | ||
|
||
var logFile = await tempFolder.CreateFileAsync($"{fileName}_{DateTime.Now:yyyy-MM-dd}.txt", CreationCollisionOption.OpenIfExists); | ||
|
||
await FileIO.AppendTextAsync(logFile, $"{DateTime.Now:T}: {message}\n"); | ||
} | ||
catch (Exception logException) | ||
{ | ||
Console.WriteLine($"Error logging to file: {logException.Message}"); | ||
} | ||
} | ||
|
||
private static async void InitiliseErrorMessage(string errorMessage, XamlRoot xamlRoot) | ||
{ | ||
ContentDialog errorDialog = new ContentDialog | ||
{ | ||
Title = "Error", | ||
Content = errorMessage, | ||
CloseButtonText = "Close", | ||
PrimaryButtonText = "Open Logs File" | ||
}; | ||
errorDialog.XamlRoot = xamlRoot; | ||
|
||
errorDialog.PrimaryButtonClick += async (sender, args) => | ||
{ | ||
StorageFolder tempFolder = ApplicationData.Current.TemporaryFolder; | ||
StorageFile logFile = await tempFolder.GetFileAsync($"ErrorLogs_{DateTime.Now:yyyy-MM-dd}.txt"); | ||
if (logFile != null) | ||
{ | ||
var options = new Windows.System.LauncherOptions(); | ||
options.DisplayApplicationPicker = false; | ||
await Windows.System.Launcher.LaunchFileAsync(logFile, options); | ||
} | ||
}; | ||
await errorDialog.ShowAsync(); | ||
} | ||
public static Task Log(string message) => LogToFile(message, "Logs"); | ||
public static Task LogError(string message) => LogToFile(message, "ErrorLogs"); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Page | ||
x:Class="RyTuneX.Views.BenchmarkPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
<ScrollView x:Name="ContentArea" HorizontalScrollMode="Disabled" Margin="-20,0,-20,10" Padding="0,5,0,5"> | ||
<StackPanel> | ||
<TextBlock x:Name="CpuUsage"/> | ||
</StackPanel> | ||
|
||
</ScrollView> | ||
</Page> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
|
||
namespace RyTuneX.Views; | ||
|
||
public sealed partial class BenchmarkPage : Page | ||
{ | ||
|
||
public BenchmarkPage() | ||
{ | ||
InitializeComponent(); | ||
LogHelper.Log("Initializing BenchmarkPage"); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.