-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Basic exception overlay * Clean up the styling a bit, not perfect but not as bad as it was
- Loading branch information
Showing
15 changed files
with
165 additions
and
19 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
10 changes: 10 additions & 0 deletions
10
src/Abstractions/NexusMods.Abstractions.Logging/IObservableExceptionSource.cs
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,10 @@ | ||
namespace NexusMods.Abstractions.Logging; | ||
|
||
/// <summary> | ||
/// A global source of exceptions that have been observed by the application. | ||
/// This allows for UI and other systems to tap into log messages. | ||
/// </summary> | ||
public interface IObservableExceptionSource | ||
{ | ||
IObservable<LogMessage> Exceptions { get; } | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Abstractions/NexusMods.Abstractions.Logging/LogMessage.cs
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,12 @@ | ||
namespace NexusMods.Abstractions.Logging; | ||
|
||
/// <summary> | ||
/// A generic log message. Exists as a record to de-couple exceptions and log messages | ||
/// from the backend logging targets | ||
/// </summary> | ||
/// <param name="Exception">The attached Exception (if any)</param> | ||
/// <param name="Message">The log's message</param> | ||
public record LogMessage(Exception? Exception, string Message) | ||
{ | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/Abstractions/NexusMods.Abstractions.Logging/NexusMods.Abstractions.Logging.csproj
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NLog" /> | ||
<PackageReference Include="System.Reactive" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,19 @@ | ||
using System.Reactive.Subjects; | ||
using NexusMods.Abstractions.Logging; | ||
using NLog; | ||
using NLog.Targets; | ||
|
||
namespace NexusMods.App; | ||
|
||
public class ObservableLoggingTarget : Target, IObservableExceptionSource | ||
{ | ||
public IObservable<LogMessage> Exceptions => _exceptions; | ||
|
||
private Subject<LogMessage> _exceptions = new(); | ||
|
||
protected override void Write(LogEventInfo logEvent) | ||
{ | ||
if (logEvent.Level == LogLevel.Error || logEvent.Level == LogLevel.Fatal) | ||
_exceptions.OnNext(new LogMessage(logEvent.Exception, logEvent.FormattedMessage)); | ||
} | ||
} |
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