diff --git a/MediaBrowser.UI/App.xaml.cs b/MediaBrowser.UI/App.xaml.cs index 16795b08ad..f2eaeb152b 100644 --- a/MediaBrowser.UI/App.xaml.cs +++ b/MediaBrowser.UI/App.xaml.cs @@ -263,7 +263,7 @@ namespace MediaBrowser.UI /// private void ShowApplicationWindow() { - var win = new MainWindow { }; + var win = new MainWindow(Logger); var config = UIKernel.Instance.Configuration; diff --git a/MediaBrowser.UI/Controller/PluginUpdater.cs b/MediaBrowser.UI/Controller/PluginUpdater.cs index 55a82dc277..c5673f2d49 100644 --- a/MediaBrowser.UI/Controller/PluginUpdater.cs +++ b/MediaBrowser.UI/Controller/PluginUpdater.cs @@ -1,5 +1,5 @@ using MediaBrowser.Common.IO; -using MediaBrowser.Common.Logging; +using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; using MediaBrowser.Model.Plugins; using System; @@ -16,13 +16,20 @@ namespace MediaBrowser.UI.Controller /// public class PluginUpdater { + private readonly ILogger _logger; + + public PluginUpdater(ILogger logger) + { + _logger = logger; + } + /// /// Updates the plugins. /// /// Task{PluginUpdateResult}. public async Task UpdatePlugins() { - Logger.LogInfo("Downloading list of installed plugins"); + _logger.Info("Downloading list of installed plugins"); var allInstalledPlugins = await UIKernel.Instance.ApiClient.GetInstalledPluginsAsync().ConfigureAwait(false); var uiPlugins = allInstalledPlugins.Where(p => p.DownloadToUI).ToList(); @@ -63,7 +70,7 @@ namespace MediaBrowser.UI.Controller if (!isPluginInstalled) { downloadPlugin = true; - Logger.LogInfo("{0} is not installed and needs to be downloaded.", pluginInfo.Name); + _logger.Info("{0} is not installed and needs to be downloaded.", pluginInfo.Name); } else { @@ -75,7 +82,7 @@ namespace MediaBrowser.UI.Controller if (downloadPlugin) { - Logger.LogInfo("{0} has an updated version on the server and needs to be downloaded. Server version: {1}, UI version: {2}", pluginInfo.Name, serverVersion, fileVersion); + _logger.Info("{0} has an updated version on the server and needs to be downloaded. Server version: {1}, UI version: {2}", pluginInfo.Name, serverVersion, fileVersion); } } @@ -83,7 +90,7 @@ namespace MediaBrowser.UI.Controller { if (UIKernel.Instance.ApplicationVersion < Version.Parse(pluginInfo.MinimumRequiredUIVersion)) { - Logger.LogWarning("Can't download new version of {0} because the application needs to be updated first.", pluginInfo.Name); + _logger.Warn("Can't download new version of {0} because the application needs to be updated first.", pluginInfo.Name); continue; } @@ -102,11 +109,11 @@ namespace MediaBrowser.UI.Controller } catch (HttpException ex) { - Logger.LogException("Error downloading {0} configuration", ex, pluginInfo.Name); + _logger.ErrorException("Error downloading {0} configuration", ex, pluginInfo.Name); } catch (IOException ex) { - Logger.LogException("Error saving plugin assembly for {0}", ex, pluginInfo.Name); + _logger.ErrorException("Error saving plugin assembly for {0}", ex, pluginInfo.Name); } } } @@ -136,19 +143,19 @@ namespace MediaBrowser.UI.Controller if (!File.Exists(path)) { download = true; - Logger.LogInfo("{0} configuration was not found needs to be downloaded.", pluginInfo.Name); + _logger.Info("{0} configuration was not found needs to be downloaded.", pluginInfo.Name); } else if (File.GetLastWriteTimeUtc(path) < pluginInfo.ConfigurationDateLastModified) { download = true; - Logger.LogInfo("{0} has an updated configuration on the server and needs to be downloaded.", pluginInfo.Name); + _logger.Info("{0} has an updated configuration on the server and needs to be downloaded.", pluginInfo.Name); } if (download) { if (UIKernel.Instance.ApplicationVersion < Version.Parse(pluginInfo.MinimumRequiredUIVersion)) { - Logger.LogWarning("Can't download updated configuration of {0} because the application needs to be updated first.", pluginInfo.Name); + _logger.Warn("Can't download updated configuration of {0} because the application needs to be updated first.", pluginInfo.Name); continue; } @@ -160,11 +167,11 @@ namespace MediaBrowser.UI.Controller } catch (HttpException ex) { - Logger.LogException("Error downloading {0} configuration", ex, pluginInfo.Name); + _logger.ErrorException("Error downloading {0} configuration", ex, pluginInfo.Name); } catch (IOException ex) { - Logger.LogException("Error saving plugin configuration to {0}", ex, path); + _logger.ErrorException("Error saving plugin configuration to {0}", ex, path); } } } @@ -179,7 +186,7 @@ namespace MediaBrowser.UI.Controller /// Task. private async Task DownloadPlugin(PluginInfo plugin) { - Logger.LogInfo("Downloading {0} Plugin", plugin.Name); + _logger.Info("Downloading {0} Plugin", plugin.Name); var path = Path.Combine(UIKernel.Instance.ApplicationPaths.PluginsPath, plugin.AssemblyFileName); @@ -207,7 +214,7 @@ namespace MediaBrowser.UI.Controller /// Task. private async Task DownloadPluginConfiguration(PluginInfo pluginInfo, string path) { - Logger.LogInfo("Downloading {0} Configuration", pluginInfo.Name); + _logger.Info("Downloading {0} Configuration", pluginInfo.Name); // First download to a MemoryStream. This way if the download is cut off, we won't be left with a partial file using (var stream = await UIKernel.Instance.ApiClient.GetPluginConfigurationFileAsync(pluginInfo.UniqueId).ConfigureAwait(false)) @@ -253,7 +260,7 @@ namespace MediaBrowser.UI.Controller } catch (IOException ex) { - Logger.LogException("Error deleting plugin assembly {0}", ex, plugin); + _logger.ErrorException("Error deleting plugin assembly {0}", ex, plugin); } } } @@ -268,7 +275,7 @@ namespace MediaBrowser.UI.Controller /// The plugin. private void DeletePlugin(string plugin) { - Logger.LogInfo("Deleting {0} Plugin", plugin); + _logger.Info("Deleting {0} Plugin", plugin); if (File.Exists(plugin)) { diff --git a/MediaBrowser.UI/Controller/UIKernel.cs b/MediaBrowser.UI/Controller/UIKernel.cs index 2c06e7b935..cfc367fb95 100644 --- a/MediaBrowser.UI/Controller/UIKernel.cs +++ b/MediaBrowser.UI/Controller/UIKernel.cs @@ -106,7 +106,7 @@ namespace MediaBrowser.UI.Controller try { - await new PluginUpdater().UpdatePlugins().ConfigureAwait(false); + await new PluginUpdater(Logger).UpdatePlugins().ConfigureAwait(false); } catch (HttpException ex) { diff --git a/MediaBrowser.UI/MainWindow.xaml.cs b/MediaBrowser.UI/MainWindow.xaml.cs index 060e951c1e..0ec60217d3 100644 --- a/MediaBrowser.UI/MainWindow.xaml.cs +++ b/MediaBrowser.UI/MainWindow.xaml.cs @@ -1,6 +1,7 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Logging; using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; using MediaBrowser.UI.Controller; using MediaBrowser.UI.Controls; @@ -76,12 +77,16 @@ namespace MediaBrowser.UI } } + private readonly ILogger _logger; + /// /// Initializes a new instance of the class. /// - public MainWindow() + public MainWindow(ILogger logger) : base() { + _logger = logger; + InitializeComponent(); } @@ -191,7 +196,7 @@ namespace MediaBrowser.UI /// The page. internal void Navigate(Page page) { - Logger.LogInfo("Navigating to " + page.GetType().Name); + _logger.Info("Navigating to " + page.GetType().Name); Dispatcher.InvokeAsync(() => PageFrame.NavigateWithTransition(page)); } diff --git a/MediaBrowser.UI/UserInput/KeyboardListener.cs b/MediaBrowser.UI/UserInput/KeyboardListener.cs index 779da42fb8..76ce8e15ab 100644 --- a/MediaBrowser.UI/UserInput/KeyboardListener.cs +++ b/MediaBrowser.UI/UserInput/KeyboardListener.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Logging; -using System; +using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -62,7 +61,6 @@ namespace MediaBrowser.UI.UserInput } catch (Exception ex) { - Logger.LogException("KeyDown event listener had an error: ", ex); } } } @@ -95,7 +93,6 @@ namespace MediaBrowser.UI.UserInput /// private static void StartListening() { - Logger.LogInfo("Attaching low-level keyboard hook"); _hookID = SetHook(_proc); } @@ -104,8 +101,6 @@ namespace MediaBrowser.UI.UserInput /// private static void StopListening() { - Logger.LogInfo("Detaching low-level keyboard hook"); - UnhookWindowsHookEx(_hookID); _hookID = IntPtr.Zero; }