logger fixes for the ui
This commit is contained in:
parent
211dd6b257
commit
2a2ee4adb3
|
@ -263,7 +263,7 @@ namespace MediaBrowser.UI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ShowApplicationWindow()
|
private void ShowApplicationWindow()
|
||||||
{
|
{
|
||||||
var win = new MainWindow { };
|
var win = new MainWindow(Logger);
|
||||||
|
|
||||||
var config = UIKernel.Instance.Configuration;
|
var config = UIKernel.Instance.Configuration;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Plugins;
|
using MediaBrowser.Model.Plugins;
|
||||||
using System;
|
using System;
|
||||||
|
@ -16,13 +16,20 @@ namespace MediaBrowser.UI.Controller
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PluginUpdater
|
public class PluginUpdater
|
||||||
{
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public PluginUpdater(ILogger logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the plugins.
|
/// Updates the plugins.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task{PluginUpdateResult}.</returns>
|
/// <returns>Task{PluginUpdateResult}.</returns>
|
||||||
public async Task<PluginUpdateResult> UpdatePlugins()
|
public async Task<PluginUpdateResult> 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 allInstalledPlugins = await UIKernel.Instance.ApiClient.GetInstalledPluginsAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
var uiPlugins = allInstalledPlugins.Where(p => p.DownloadToUI).ToList();
|
var uiPlugins = allInstalledPlugins.Where(p => p.DownloadToUI).ToList();
|
||||||
|
@ -63,7 +70,7 @@ namespace MediaBrowser.UI.Controller
|
||||||
if (!isPluginInstalled)
|
if (!isPluginInstalled)
|
||||||
{
|
{
|
||||||
downloadPlugin = true;
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -75,7 +82,7 @@ namespace MediaBrowser.UI.Controller
|
||||||
|
|
||||||
if (downloadPlugin)
|
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))
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,11 +109,11 @@ namespace MediaBrowser.UI.Controller
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpException ex)
|
||||||
{
|
{
|
||||||
Logger.LogException("Error downloading {0} configuration", ex, pluginInfo.Name);
|
_logger.ErrorException("Error downloading {0} configuration", ex, pluginInfo.Name);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
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))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
download = true;
|
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)
|
else if (File.GetLastWriteTimeUtc(path) < pluginInfo.ConfigurationDateLastModified)
|
||||||
{
|
{
|
||||||
download = true;
|
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 (download)
|
||||||
{
|
{
|
||||||
if (UIKernel.Instance.ApplicationVersion < Version.Parse(pluginInfo.MinimumRequiredUIVersion))
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,11 +167,11 @@ namespace MediaBrowser.UI.Controller
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpException ex)
|
||||||
{
|
{
|
||||||
Logger.LogException("Error downloading {0} configuration", ex, pluginInfo.Name);
|
_logger.ErrorException("Error downloading {0} configuration", ex, pluginInfo.Name);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
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
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task DownloadPlugin(PluginInfo plugin)
|
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);
|
var path = Path.Combine(UIKernel.Instance.ApplicationPaths.PluginsPath, plugin.AssemblyFileName);
|
||||||
|
|
||||||
|
@ -207,7 +214,7 @@ namespace MediaBrowser.UI.Controller
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task DownloadPluginConfiguration(PluginInfo pluginInfo, string path)
|
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
|
// 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))
|
using (var stream = await UIKernel.Instance.ApiClient.GetPluginConfigurationFileAsync(pluginInfo.UniqueId).ConfigureAwait(false))
|
||||||
|
@ -253,7 +260,7 @@ namespace MediaBrowser.UI.Controller
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
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
|
||||||
/// <param name="plugin">The plugin.</param>
|
/// <param name="plugin">The plugin.</param>
|
||||||
private void DeletePlugin(string plugin)
|
private void DeletePlugin(string plugin)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Deleting {0} Plugin", plugin);
|
_logger.Info("Deleting {0} Plugin", plugin);
|
||||||
|
|
||||||
if (File.Exists(plugin))
|
if (File.Exists(plugin))
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace MediaBrowser.UI.Controller
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await new PluginUpdater().UpdatePlugins().ConfigureAwait(false);
|
await new PluginUpdater(Logger).UpdatePlugins().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpException ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Logging;
|
using MediaBrowser.Common.Logging;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.UI.Controller;
|
using MediaBrowser.UI.Controller;
|
||||||
using MediaBrowser.UI.Controls;
|
using MediaBrowser.UI.Controls;
|
||||||
|
@ -76,12 +77,16 @@ namespace MediaBrowser.UI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="MainWindow" /> class.
|
/// Initializes a new instance of the <see cref="MainWindow" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MainWindow()
|
public MainWindow(ILogger logger)
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
|
_logger = logger;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +196,7 @@ namespace MediaBrowser.UI
|
||||||
/// <param name="page">The page.</param>
|
/// <param name="page">The page.</param>
|
||||||
internal void Navigate(Page 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));
|
Dispatcher.InvokeAsync(() => PageFrame.NavigateWithTransition(page));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using MediaBrowser.Common.Logging;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
@ -62,7 +61,6 @@ namespace MediaBrowser.UI.UserInput
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogException("KeyDown event listener had an error: ", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +93,6 @@ namespace MediaBrowser.UI.UserInput
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void StartListening()
|
private static void StartListening()
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Attaching low-level keyboard hook");
|
|
||||||
_hookID = SetHook(_proc);
|
_hookID = SetHook(_proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +101,6 @@ namespace MediaBrowser.UI.UserInput
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void StopListening()
|
private static void StopListening()
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Detaching low-level keyboard hook");
|
|
||||||
|
|
||||||
UnhookWindowsHookEx(_hookID);
|
UnhookWindowsHookEx(_hookID);
|
||||||
_hookID = IntPtr.Zero;
|
_hookID = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user