diff --git a/Penumbra/Import/Models/IoNotifier.cs b/Penumbra/Import/Models/IoNotifier.cs index e1d649f6..56ef7103 100644 --- a/Penumbra/Import/Models/IoNotifier.cs +++ b/Penumbra/Import/Models/IoNotifier.cs @@ -1,19 +1,11 @@ -using Dalamud.Interface.Internal.Notifications; -using OtterGui.Classes; +using OtterGui.Log; namespace Penumbra.Import.Models; public record class IoNotifier { - /// Notification subclass so that we have a distinct type to filter by. - private class LegallyDistinctNotification : Notification - { - public LegallyDistinctNotification(string content, NotificationType type): base(content, type) - {} - } - - private readonly DateTime _startTime = DateTime.UtcNow; - private string _context = ""; + private readonly List _messages = []; + private string _context = ""; /// Create a new notifier with the specified context appended to any other context already present. public IoNotifier WithContext(string context) @@ -21,12 +13,12 @@ public record class IoNotifier /// Send a warning with any current context to notification channels. public void Warning(string content) - => SendNotification(content, NotificationType.Warning); + => SendMessage(content, Logger.LogLevel.Warning); /// Get the current warnings for this notifier. /// This does not currently filter to notifications with the current notifier's context - it will return all IO notifications from all notifiers. public IEnumerable GetWarnings() - => GetFilteredNotifications(NotificationType.Warning); + => _messages; /// Create an exception with any current context. [StackTraceHidden] @@ -39,14 +31,10 @@ public record class IoNotifier where TException : Exception, new() => (TException)Activator.CreateInstance(typeof(TException), $"{_context}{message}")!; - private void SendNotification(string message, NotificationType type) - => Penumbra.Messager.AddMessage( - new LegallyDistinctNotification($"{_context}{message}", type), - true, false, true, false - ); - - private IEnumerable GetFilteredNotifications(NotificationType type) - => Penumbra.Messager - .Where(p => p.Key >= _startTime && p.Value is LegallyDistinctNotification && p.Value.NotificationType == type) - .Select(p => p.Value.PrintMessage); + private void SendMessage(string message, Logger.LogLevel type) + { + var fullText = $"{_context}{message}"; + Penumbra.Log.Message(type, fullText); + _messages.Add(fullText); + } }