-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add LogHandler service for improved log processing Introduced a new LogHandler class to manage and process log data more effectively. Integrated LogHandler into OverviewPageViewModel and ServiceLocator for better error handling and logging capabilities. * Add detailed installation instructions to README.md This update includes prerequisites, step-by-step installation commands, troubleshooting tips, updating instructions, and uninstallation steps for the GamerVII Launcher. These additions aim to provide clear, comprehensive guidance for users to correctly install, update, and uninstall the launcher. * Add README.md to Gml.Client project in solution This commit updates the solution file to include the README.md for the Gml.Client project. The addition helps in documenting the project directly within the solution, providing better context and guidance for developers. * Update submodule link Gml.Client * Prevent further processing of error data Added a return statement at the beginning of the HandleErrorData method to immediately exit the function. This ensures that no additional code is executed within this method when it is called. --------- Co-authored-by: GamerVII-NET <[email protected]>
- Loading branch information
1 parent
f999ab8
commit bc23fb4
Showing
19 changed files
with
307 additions
and
78 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
Submodule Gml.Client
updated
from 23e044 to faec62
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,76 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Reactive.Linq; | ||
using System.Reactive.Subjects; | ||
using System.Text.RegularExpressions; | ||
using Sentry; | ||
|
||
namespace Gml.Launcher.Core.Services; | ||
|
||
public class LogHandler | ||
{ | ||
private readonly Subject<string> _errorDataSubject = new(); | ||
|
||
|
||
public LogHandler() | ||
{ | ||
var errorDataObservable = _errorDataSubject | ||
.Where(data => !string.IsNullOrEmpty(data)) | ||
.Buffer(() => _errorDataSubject.Where(data => data.Contains("</log4j:Event>"))) | ||
.Select(lines => string.Join(Environment.NewLine, lines)); | ||
|
||
errorDataObservable.Subscribe(HandleErrorData); | ||
} | ||
|
||
private void HandleErrorData(string data) | ||
{ | ||
return; | ||
Debug.WriteLine(data); | ||
|
||
if (data.Contains("Exception", StringComparison.OrdinalIgnoreCase) || | ||
data.Contains("<log4j:Throwable>", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
var exception = ExtractException(data); | ||
ShowError(ResourceKeysDictionary.GameProfileError, data); | ||
SentrySdk.CaptureException(exception); | ||
} | ||
|
||
if (data.Contains("[gml-patch]", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
} | ||
else | ||
{ | ||
ShowError(ResourceKeysDictionary.GameProfileError, data); | ||
SentrySdk.CaptureException(new Exception(data)); | ||
} | ||
} | ||
|
||
private Exception ExtractException(string data) | ||
{ | ||
var throwableRegex = new Regex(@"<log4j:Throwable><!\[CDATA\[(.*?)\]\]></log4j:Throwable>", RegexOptions.Singleline); | ||
var match = throwableRegex.Match(data); | ||
|
||
if (match.Success) | ||
{ | ||
var stackTrace = match.Groups[1].Value; | ||
return new Exception(stackTrace); | ||
} | ||
|
||
return new Exception(data); | ||
} | ||
|
||
private void ShowError(string key, string message) | ||
{ | ||
// Реализуйте здесь показ ошибок пользователю | ||
} | ||
|
||
private static class ResourceKeysDictionary | ||
{ | ||
public static string GameProfileError = "GameProfileError"; | ||
} | ||
|
||
public void ProcessLogs(string data) | ||
{ | ||
_errorDataSubject.OnNext(data); | ||
} | ||
} |
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
Oops, something went wrong.