diff --git a/src/OneWare.Core/Services/Logger.cs b/src/OneWare.Core/Services/Logger.cs index faf15ecf..cfdfddf0 100644 --- a/src/OneWare.Core/Services/Logger.cs +++ b/src/OneWare.Core/Services/Logger.cs @@ -59,12 +59,13 @@ public void Log(object message, ConsoleColor color = default, bool writeOutput = public void Error(string message, Exception? exception = null, bool showOutput = true, bool showDialog = false, Window? dialogOwner = null) { - Log(message + "\n" + exception, ConsoleColor.Red); + var output = message + (exception != null ? $"\n{exception}" : ""); + Log(output, ConsoleColor.Red); if (showOutput && ContainerLocator.Container.IsRegistered()) Dispatcher.UIThread.Post(() => { - ContainerLocator.Current.Resolve().WriteLine("[Error]: " + message, Brushes.Red); + ContainerLocator.Current.Resolve().WriteLine(output, Brushes.Red); ContainerLocator.Current.Resolve() .Show(ContainerLocator.Current.Resolve()); }); @@ -73,24 +74,25 @@ public void Error(string message, Exception? exception = null, bool showOutput = Dispatcher.UIThread.Post(() => { _ = ContainerLocator.Current.Resolve() - .ShowMessageAsync("Error", message, MessageBoxIcon.Error, dialogOwner); + .ShowMessageAsync("Error", output, MessageBoxIcon.Error, dialogOwner); }); } public void Warning(string message, Exception? exception = null, bool showOutput = true, bool showDialog = false, Window? dialogOwner = null) { - Log(message + "\n" + exception, ConsoleColor.Yellow); + var output = message + (exception != null ? $"\n{exception}" : ""); + Log(output, ConsoleColor.Yellow); if (showOutput && ContainerLocator.Container.IsRegistered()) { - ContainerLocator.Current.Resolve().WriteLine("[Warning]: " + message, Brushes.Orange); + ContainerLocator.Current.Resolve().WriteLine(output, Brushes.Orange); ContainerLocator.Current.Resolve().Show(ContainerLocator.Current.Resolve()); } if (showDialog) _ = ContainerLocator.Current.Resolve() - .ShowMessageAsync("Warning", message, MessageBoxIcon.Warning, dialogOwner); + .ShowMessageAsync("Warning", output, MessageBoxIcon.Warning, dialogOwner); } private void Init()