Add more logs to plugin window

This commit is contained in:
Stone_Red
2023-11-21 15:24:16 +01:00
parent 719d2ef290
commit 1f9e123893
@@ -121,6 +121,7 @@ public partial class PluginWindow : Window
private void Window_ContentRendered(object? sender, EventArgs e) private void Window_ContentRendered(object? sender, EventArgs e)
{ {
App.Logger.Log($"\"{PluginName}\" - Starting plugin thread", "Plugin");
pluginThread = new Thread(LoadPlugin); pluginThread = new Thread(LoadPlugin);
pluginThread.Start(); pluginThread.Start();
} }
@@ -162,13 +163,17 @@ public partial class PluginWindow : Window
private void LoadPlugin() private void LoadPlugin()
{ {
App.Logger.Log($"\"{PluginName}\" - Loading plugin", "Plugin");
if (pluginClassInstance is null) if (pluginClassInstance is null)
{ {
PluginFolderPath = $"{App.ApplicationDataPath}\\Plugins\\{PluginName}"; PluginFolderPath = $"{App.ApplicationDataPath}\\Plugins\\{PluginName}";
if (!File.Exists($"{PluginFolderPath}\\{PluginName}.dll")) if (!File.Exists($"{PluginFolderPath}\\{PluginName}.dll"))
{ {
App.Logger.Log($"\"{PluginName}\" - File does not exist", "Plugin", LogSeverity.Error);
_ = MessageBox.Show("File does not exist!", $"Error \"{PluginName}\"", MessageBoxButton.OK, MessageBoxImage.Error); _ = MessageBox.Show("File does not exist!", $"Error \"{PluginName}\"", MessageBoxButton.OK, MessageBoxImage.Error);
Exit(); Exit();
return; return;
} }
@@ -199,7 +204,9 @@ public partial class PluginWindow : Window
if (instanceType is null) if (instanceType is null)
{ {
App.Logger.Log($"\"{PluginName}\" - The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", "Plugin", LogSeverity.Error);
_ = MessageBox.Show($"The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", $"Error \"{PluginName}\"", MessageBoxButton.OK, MessageBoxImage.Error); _ = MessageBox.Show($"The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", $"Error \"{PluginName}\"", MessageBoxButton.OK, MessageBoxImage.Error);
Exit(); Exit();
return; return;
} }
@@ -213,6 +220,7 @@ public partial class PluginWindow : Window
} }
else else
{ {
App.Logger.Log($"\"{PluginName}\" - The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", "Plugin", LogSeverity.Error);
_ = MessageBox.Show($"The \"Plugin\" class has to inherit from \"{typeof(Plugin).FullName}\"", $"Error \"{PluginName}\"", MessageBoxButton.OK, MessageBoxImage.Error); _ = MessageBox.Show($"The \"Plugin\" class has to inherit from \"{typeof(Plugin).FullName}\"", $"Error \"{PluginName}\"", MessageBoxButton.OK, MessageBoxImage.Error);
Exit(); Exit();
return; return;
@@ -238,6 +246,8 @@ public partial class PluginWindow : Window
private void LoadOptions(object instance) private void LoadOptions(object instance)
{ {
App.Logger.Log($"\"{PluginName}\" - Loading plugin options", "Plugin");
try try
{ {
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields #pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
@@ -325,6 +335,7 @@ public partial class PluginWindow : Window
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
App.Logger.Log($"\"{PluginName}\" - Stopping plugin", "Plugin");
pluginClassInstance?.Stop(); pluginClassInstance?.Stop();
IsRunning = false; IsRunning = false;
} }