extracted more logging dependancies

This commit is contained in:
LukePulverenti 2013-02-21 16:06:23 -05:00
parent 2a2ee4adb3
commit 76f067f867
22 changed files with 153 additions and 112 deletions

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Logging;
using System;
using System.Threading.Tasks;
@ -10,18 +9,14 @@ namespace MediaBrowser.Common.Events
/// </summary>
public static class EventHelper
{
/// <summary>
/// The logger
/// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("EventHelper");
/// <summary>
/// Fires the event.
/// </summary>
/// <param name="handler">The handler.</param>
/// <param name="sender">The sender.</param>
/// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param>
public static void QueueEventIfNotNull(EventHandler handler, object sender, EventArgs args)
/// <param name="logger">The logger.</param>
public static void QueueEventIfNotNull(EventHandler handler, object sender, EventArgs args, ILogger logger)
{
if (handler != null)
{
@ -33,7 +28,7 @@ namespace MediaBrowser.Common.Events
}
catch (Exception ex)
{
Logger.ErrorException("Error in event handler", ex);
logger.ErrorException("Error in event handler", ex);
}
});
}
@ -46,7 +41,8 @@ namespace MediaBrowser.Common.Events
/// <param name="handler">The handler.</param>
/// <param name="sender">The sender.</param>
/// <param name="args">The args.</param>
public static void QueueEventIfNotNull<T>(EventHandler<T> handler, object sender, T args)
/// <param name="logger">The logger.</param>
public static void QueueEventIfNotNull<T>(EventHandler<T> handler, object sender, T args, ILogger logger)
{
if (handler != null)
{
@ -58,7 +54,7 @@ namespace MediaBrowser.Common.Events
}
catch (Exception ex)
{
Logger.ErrorException("Error in event handler", ex);
logger.ErrorException("Error in event handler", ex);
}
});
}
@ -70,7 +66,8 @@ namespace MediaBrowser.Common.Events
/// <param name="handler">The handler.</param>
/// <param name="sender">The sender.</param>
/// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param>
public static void FireEventIfNotNull(EventHandler handler, object sender, EventArgs args)
/// <param name="logger">The logger.</param>
public static void FireEventIfNotNull(EventHandler handler, object sender, EventArgs args, ILogger logger)
{
if (handler != null)
{
@ -80,7 +77,7 @@ namespace MediaBrowser.Common.Events
}
catch (Exception ex)
{
Logger.ErrorException("Error in event handler", ex);
logger.ErrorException("Error in event handler", ex);
}
}
}
@ -92,7 +89,8 @@ namespace MediaBrowser.Common.Events
/// <param name="handler">The handler.</param>
/// <param name="sender">The sender.</param>
/// <param name="args">The args.</param>
public static void FireEventIfNotNull<T>(EventHandler<T> handler, object sender, T args)
/// <param name="logger">The logger.</param>
public static void FireEventIfNotNull<T>(EventHandler<T> handler, object sender, T args, ILogger logger)
{
if (handler != null)
{
@ -102,7 +100,7 @@ namespace MediaBrowser.Common.Events
}
catch (Exception ex)
{
Logger.ErrorException("Error in event handler", ex);
logger.ErrorException("Error in event handler", ex);
}
}
}

View File

@ -56,7 +56,7 @@ namespace MediaBrowser.Common.Kernel
/// </summary>
internal void OnConfigurationUpdated()
{
EventHelper.QueueEventIfNotNull(ConfigurationUpdated, this, EventArgs.Empty);
EventHelper.QueueEventIfNotNull(ConfigurationUpdated, this, EventArgs.Empty, Logger);
// Notify connected clients
TcpManager.SendWebSocketMessage("ConfigurationUpdated", Configuration);
@ -73,7 +73,7 @@ namespace MediaBrowser.Common.Kernel
/// </summary>
private void OnLoggerLoaded()
{
EventHelper.QueueEventIfNotNull(LoggerLoaded, this, EventArgs.Empty);
EventHelper.QueueEventIfNotNull(LoggerLoaded, this, EventArgs.Empty, Logger);
}
#endregion
@ -87,7 +87,7 @@ namespace MediaBrowser.Common.Kernel
/// </summary>
private void OnReloadBeginning()
{
EventHelper.QueueEventIfNotNull(ReloadBeginning, this, EventArgs.Empty);
EventHelper.QueueEventIfNotNull(ReloadBeginning, this, EventArgs.Empty, Logger);
}
#endregion
@ -101,7 +101,7 @@ namespace MediaBrowser.Common.Kernel
/// </summary>
private void OnReloadCompleted()
{
EventHelper.QueueEventIfNotNull(ReloadCompleted, this, EventArgs.Empty);
EventHelper.QueueEventIfNotNull(ReloadCompleted, this, EventArgs.Empty, Logger);
}
#endregion
@ -116,7 +116,7 @@ namespace MediaBrowser.Common.Kernel
/// <param name="newVersion">The new version.</param>
public void OnApplicationUpdated(Version newVersion)
{
EventHelper.QueueEventIfNotNull(ApplicationUpdated, this, new GenericEventArgs<Version> { Argument = newVersion });
EventHelper.QueueEventIfNotNull(ApplicationUpdated, this, new GenericEventArgs<Version> { Argument = newVersion }, Logger);
NotifyPendingRestart();
}
@ -351,9 +351,21 @@ namespace MediaBrowser.Common.Kernel
/// Initializes a new instance of the <see cref="BaseKernel{TApplicationPathsType}" /> class.
/// </summary>
/// <param name="isoManager">The iso manager.</param>
protected BaseKernel(IIsoManager isoManager)
/// <param name="logger">The logger.</param>
protected BaseKernel(IIsoManager isoManager, ILogger logger)
{
if (isoManager == null)
{
throw new ArgumentNullException("isoManager");
}
if (logger == null)
{
throw new ArgumentNullException("logger");
}
IsoManager = isoManager;
Logger = logger;
}
/// <summary>
@ -362,8 +374,6 @@ namespace MediaBrowser.Common.Kernel
/// <returns>Task.</returns>
public async Task Init()
{
Logger = Logging.LogManager.GetLogger(GetType().Name);
ApplicationPaths = new TApplicationPathsType();
IsFirstRun = !File.Exists(ApplicationPaths.SystemConfigurationFilePath);
@ -496,7 +506,7 @@ namespace MediaBrowser.Common.Kernel
/// <param name="container">The container.</param>
protected virtual void ComposeExportedValues(CompositionContainer container)
{
container.ComposeExportedValue("logger", Logging.LogManager.GetLogger("App"));
container.ComposeExportedValue("logger", Logger);
}
/// <summary>
@ -588,7 +598,7 @@ namespace MediaBrowser.Common.Kernel
try
{
plugin.Initialize(this, Logging.LogManager.GetLogger(plugin.GetType().Name));
plugin.Initialize(this, Logger);
Logger.Info("{0} {1} initialized.", plugin.Name, plugin.Version);
}
@ -609,7 +619,7 @@ namespace MediaBrowser.Common.Kernel
TcpManager.SendWebSocketMessage("HasPendingRestartChanged", GetSystemInfo());
EventHelper.QueueEventIfNotNull(HasPendingRestartChanged, this, EventArgs.Empty);
EventHelper.QueueEventIfNotNull(HasPendingRestartChanged, this, EventArgs.Empty, Logger);
}
/// <summary>
@ -749,7 +759,7 @@ namespace MediaBrowser.Common.Kernel
{
Logger.Info("Restarting the application");
EventHelper.QueueEventIfNotNull(ApplicationRestartRequested, this, EventArgs.Empty);
EventHelper.QueueEventIfNotNull(ApplicationRestartRequested, this, EventArgs.Empty, Logger);
}
/// <summary>

View File

@ -150,7 +150,7 @@ namespace MediaBrowser.Common.Kernel
/// <param name="context">The context.</param>
private void OnAlchemyWebSocketClientConnected(UserContext context)
{
var connection = new WebSocketConnection(new AlchemyWebSocket(context), context.ClientAddress, ProcessWebSocketMessageReceived);
var connection = new WebSocketConnection(new AlchemyWebSocket(context, Logger), context.ClientAddress, ProcessWebSocketMessageReceived, Logger);
_webSocketConnections.Add(connection);
}
@ -173,7 +173,7 @@ namespace MediaBrowser.Common.Kernel
try
{
HttpServer = new HttpServer(Kernel.HttpServerUrlPrefix, "Media Browser", Kernel);
HttpServer = new HttpServer(Kernel.HttpServerUrlPrefix, "Media Browser", Kernel, Logger);
}
catch (HttpListenerException ex)
{
@ -202,7 +202,7 @@ namespace MediaBrowser.Common.Kernel
/// <param name="e">The <see cref="WebSocketConnectEventArgs" /> instance containing the event data.</param>
void HttpServer_WebSocketConnected(object sender, WebSocketConnectEventArgs e)
{
var connection = new WebSocketConnection(e.WebSocket, e.Endpoint, ProcessWebSocketMessageReceived);
var connection = new WebSocketConnection(e.WebSocket, e.Endpoint, ProcessWebSocketMessageReceived, Logger);
_webSocketConnections.Add(connection);
}

View File

@ -17,7 +17,7 @@ namespace MediaBrowser.Common.Net
/// <summary>
/// The logger
/// </summary>
private static ILogger Logger = LogManager.GetLogger("AlchemyWebSocket");
private readonly ILogger _logger;
/// <summary>
/// Gets or sets the web socket.
@ -29,20 +29,22 @@ namespace MediaBrowser.Common.Net
/// Initializes a new instance of the <see cref="AlchemyWebSocket" /> class.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">context</exception>
public AlchemyWebSocket(UserContext context)
public AlchemyWebSocket(UserContext context, ILogger logger)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
_logger = logger;
UserContext = context;
context.SetOnDisconnect(OnDisconnected);
context.SetOnReceive(OnReceive);
Logger.Info("Client connected from {0}", context.ClientAddress);
_logger.Info("Client connected from {0}", context.ClientAddress);
}
/// <summary>
@ -87,7 +89,7 @@ namespace MediaBrowser.Common.Net
}
catch (Exception ex)
{
Logger.ErrorException("Error processing web socket message", ex);
_logger.ErrorException("Error processing web socket message", ex);
}
}
}

View File

@ -32,7 +32,7 @@ namespace MediaBrowser.Common.Net
/// <summary>
/// The logger
/// </summary>
private static ILogger Logger = Logging.LogManager.GetLogger("HttpServer");
private readonly ILogger _logger;
/// <summary>
/// Gets the URL prefix.
@ -69,17 +69,27 @@ namespace MediaBrowser.Common.Net
/// <param name="urlPrefix">The URL.</param>
/// <param name="serverName">Name of the product.</param>
/// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
/// <param name="defaultRedirectpath">The default redirectpath.</param>
/// <exception cref="System.ArgumentNullException">urlPrefix</exception>
public HttpServer(string urlPrefix, string serverName, IKernel kernel, string defaultRedirectpath = null)
public HttpServer(string urlPrefix, string serverName, IKernel kernel, ILogger logger, string defaultRedirectpath = null)
: base()
{
if (string.IsNullOrEmpty(urlPrefix))
{
throw new ArgumentNullException("urlPrefix");
}
if (kernel == null)
{
throw new ArgumentNullException("kernel");
}
if (logger == null)
{
throw new ArgumentNullException("logger");
}
DefaultRedirectPath = defaultRedirectpath;
_logger = logger;
EndpointHostConfig.Instance.ServiceStackHandlerFactoryPath = null;
EndpointHostConfig.Instance.MetadataRedirectPath = "metadata";
@ -274,12 +284,12 @@ namespace MediaBrowser.Common.Net
if (WebSocketConnected != null)
{
WebSocketConnected(this, new WebSocketConnectEventArgs { WebSocket = new NativeWebSocket(webSocketContext.WebSocket), Endpoint = ctx.Request.RemoteEndPoint });
WebSocketConnected(this, new WebSocketConnectEventArgs { WebSocket = new NativeWebSocket(webSocketContext.WebSocket, _logger), Endpoint = ctx.Request.RemoteEndPoint });
}
}
catch (Exception ex)
{
Logger.ErrorException("AcceptWebSocketAsync error", ex);
_logger.ErrorException("AcceptWebSocketAsync error", ex);
ctx.Response.StatusCode = 500;
ctx.Response.Close();
@ -301,7 +311,7 @@ namespace MediaBrowser.Common.Net
if (Kernel.Configuration.EnableHttpLevelLogging)
{
Logger.LogMultiline(type + " request received from " + ctx.Request.RemoteEndPoint, LogSeverity.Debug, log);
_logger.LogMultiline(type + " request received from " + ctx.Request.RemoteEndPoint, LogSeverity.Debug, log);
}
}
@ -313,7 +323,7 @@ namespace MediaBrowser.Common.Net
/// <param name="statusCode">The status code.</param>
private void HandleException(HttpListenerResponse response, Exception ex, int statusCode)
{
Logger.ErrorException("Error processing request", ex);
_logger.ErrorException("Error processing request", ex);
response.StatusCode = statusCode;
@ -352,7 +362,7 @@ namespace MediaBrowser.Common.Net
}
catch (Exception errorEx)
{
Logger.ErrorException("Error processing failed request", errorEx);
_logger.ErrorException("Error processing failed request", errorEx);
}
}
@ -408,7 +418,7 @@ namespace MediaBrowser.Common.Net
if (Kernel.Configuration.EnableHttpLevelLogging)
{
Logger.LogMultiline(msg, LogSeverity.Debug, log);
_logger.LogMultiline(msg, LogSeverity.Debug, log);
}
}

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Logging;
using MediaBrowser.Common.Serialization;
using MediaBrowser.Common.Serialization;
using MediaBrowser.Model.Logging;
using System;
using System.IO;
@ -17,7 +16,7 @@ namespace MediaBrowser.Common.Net
/// <summary>
/// The logger
/// </summary>
private static ILogger Logger = LogManager.GetLogger("NativeWebSocket");
private readonly ILogger _logger;
/// <summary>
/// Gets or sets the web socket.
@ -29,14 +28,21 @@ namespace MediaBrowser.Common.Net
/// Initializes a new instance of the <see cref="NativeWebSocket" /> class.
/// </summary>
/// <param name="socket">The socket.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">socket</exception>
public NativeWebSocket(WebSocket socket)
public NativeWebSocket(WebSocket socket, ILogger logger)
{
if (socket == null)
{
throw new ArgumentNullException("socket");
}
if (logger == null)
{
throw new ArgumentNullException("logger");
}
_logger = logger;
WebSocket = socket;
Receive();
@ -66,7 +72,7 @@ namespace MediaBrowser.Common.Net
}
catch (WebSocketException ex)
{
Logger.ErrorException("Error reveiving web socket message", ex);
_logger.ErrorException("Error reveiving web socket message", ex);
break;
}
@ -83,7 +89,7 @@ namespace MediaBrowser.Common.Net
}
catch (Exception ex)
{
Logger.ErrorException("Error processing web socket message", ex);
_logger.ErrorException("Error processing web socket message", ex);
}
}
}

View File

@ -37,7 +37,7 @@ namespace MediaBrowser.Common.Net
/// <summary>
/// The logger
/// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("WebSocketConnection");
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="WebSocketConnection" /> class.
@ -46,7 +46,7 @@ namespace MediaBrowser.Common.Net
/// <param name="remoteEndPoint">The remote end point.</param>
/// <param name="receiveAction">The receive action.</param>
/// <exception cref="System.ArgumentNullException">socket</exception>
public WebSocketConnection(IWebSocket socket, EndPoint remoteEndPoint, Action<WebSocketMessageInfo> receiveAction)
public WebSocketConnection(IWebSocket socket, EndPoint remoteEndPoint, Action<WebSocketMessageInfo> receiveAction, ILogger logger)
{
if (socket == null)
{
@ -60,10 +60,15 @@ namespace MediaBrowser.Common.Net
{
throw new ArgumentNullException("receiveAction");
}
if (logger == null)
{
throw new ArgumentNullException("logger");
}
_socket = socket;
_socket.OnReceiveDelegate = info => OnReceive(info, receiveAction);
RemoteEndPoint = remoteEndPoint;
_logger = logger;
}
/// <summary>
@ -81,7 +86,7 @@ namespace MediaBrowser.Common.Net
}
catch (Exception ex)
{
Logger.ErrorException("Error processing web socket message", ex);
_logger.ErrorException("Error processing web socket message", ex);
}
}
@ -148,13 +153,13 @@ namespace MediaBrowser.Common.Net
}
catch (OperationCanceledException)
{
Logger.Info("WebSocket message to {0} was cancelled", RemoteEndPoint);
_logger.Info("WebSocket message to {0} was cancelled", RemoteEndPoint);
throw;
}
catch (Exception ex)
{
Logger.ErrorException("Error sending WebSocket message {0}", ex, RemoteEndPoint);
_logger.ErrorException("Error sending WebSocket message {0}", ex, RemoteEndPoint);
throw;
}

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Logging;
using MediaBrowser.Common.Updates;
using MediaBrowser.Model.Logging;
using Microsoft.Win32;
@ -84,9 +83,10 @@ namespace MediaBrowser.Common.UI
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplication" /> class.
/// </summary>
protected BaseApplication()
/// <param name="logger">The logger.</param>
protected BaseApplication(ILogger logger)
{
Logger = LogManager.GetLogger("App");
Logger = logger;
}
/// <summary>
@ -397,20 +397,6 @@ namespace MediaBrowser.Common.UI
RenderOptions.SetBitmapScalingMode(bitmap, BitmapScalingMode.Fant);
return bitmap;
}
/// <summary>
/// Runs the application.
/// </summary>
/// <typeparam name="TApplicationType">The type of the T application type.</typeparam>
/// <param name="uniqueKey">The unique key.</param>
public static void RunApplication<TApplicationType>(string uniqueKey)
where TApplicationType : BaseApplication, IApplication, new()
{
var application = new TApplicationType();
application.InitializeComponent();
application.Run();
}
}
/// <summary>

View File

@ -345,7 +345,7 @@ namespace MediaBrowser.Controller.Entities
// When resolving the root, we need it's grandchildren (children of user views)
var flattenFolderDepth = args.IsPhysicalRoot ? 2 : 0;
args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, flattenFolderDepth: flattenFolderDepth, args: args);
args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, Logger, flattenFolderDepth: flattenFolderDepth, args: args);
}
//update our dates

View File

@ -202,14 +202,12 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Dictionary{System.StringIComparer{BaseItem}}.</returns>
protected virtual Dictionary<string, IComparer<BaseItem>> GetSortByOptions()
{
var logger = LogManager.GetLogger("BaseItemComparer");
return new Dictionary<string, IComparer<BaseItem>> {
{LocalizedStrings.Instance.GetString("NameDispPref"), new BaseItemComparer(SortOrder.Name, logger)},
{LocalizedStrings.Instance.GetString("DateDispPref"), new BaseItemComparer(SortOrder.Date, logger)},
{LocalizedStrings.Instance.GetString("RatingDispPref"), new BaseItemComparer(SortOrder.Rating, logger)},
{LocalizedStrings.Instance.GetString("RuntimeDispPref"), new BaseItemComparer(SortOrder.Runtime, logger)},
{LocalizedStrings.Instance.GetString("YearDispPref"), new BaseItemComparer(SortOrder.Year, logger)}
{LocalizedStrings.Instance.GetString("NameDispPref"), new BaseItemComparer(SortOrder.Name, Logger)},
{LocalizedStrings.Instance.GetString("DateDispPref"), new BaseItemComparer(SortOrder.Date, Logger)},
{LocalizedStrings.Instance.GetString("RatingDispPref"), new BaseItemComparer(SortOrder.Rating, Logger)},
{LocalizedStrings.Instance.GetString("RuntimeDispPref"), new BaseItemComparer(SortOrder.Runtime, Logger)},
{LocalizedStrings.Instance.GetString("YearDispPref"), new BaseItemComparer(SortOrder.Year, Logger)}
};
}
@ -223,7 +221,7 @@ namespace MediaBrowser.Controller.Entities
{
IComparer<BaseItem> sorting;
SortByOptions.TryGetValue(name ?? "", out sorting);
return sorting ?? new BaseItemComparer(SortOrder.Name, LogManager.GetLogger("BaseItemComparer"));
return sorting ?? new BaseItemComparer(SortOrder.Name, Logger);
}
/// <summary>

View File

@ -15,15 +15,11 @@ namespace MediaBrowser.Controller.IO
/// </summary>
public static class FileData
{
/// <summary>
/// The logger
/// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("FileData");
/// <summary>
/// Gets all file system entries within a foler
/// </summary>
/// <param name="path">The path.</param>
/// <param name="logger">The logger.</param>
/// <param name="searchPattern">The search pattern.</param>
/// <param name="includeFiles">if set to <c>true</c> [include files].</param>
/// <param name="includeDirectories">if set to <c>true</c> [include directories].</param>
@ -32,7 +28,7 @@ namespace MediaBrowser.Controller.IO
/// <returns>Dictionary{System.StringWIN32_FIND_DATA}.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
/// <exception cref="System.IO.IOException">GetFileSystemEntries failed</exception>
public static Dictionary<string, WIN32_FIND_DATA> GetFilteredFileSystemEntries(string path, string searchPattern = "*", bool includeFiles = true, bool includeDirectories = true, int flattenFolderDepth = 0, ItemResolveArgs args = null)
public static Dictionary<string, WIN32_FIND_DATA> GetFilteredFileSystemEntries(string path, ILogger logger, string searchPattern = "*", bool includeFiles = true, bool includeDirectories = true, int flattenFolderDepth = 0, ItemResolveArgs args = null)
{
if (string.IsNullOrEmpty(path))
{
@ -93,7 +89,7 @@ namespace MediaBrowser.Controller.IO
if (string.IsNullOrWhiteSpace(newPath))
{
//invalid shortcut - could be old or target could just be unavailable
Logger.Warn("Encountered invalid shortuct: "+lpFindFileData.Path);
logger.Warn("Encountered invalid shortuct: " + lpFindFileData.Path);
continue;
}
var data = FileSystem.GetFileData(newPath);
@ -117,7 +113,7 @@ namespace MediaBrowser.Controller.IO
}
else if (flattenFolderDepth > 0 && lpFindFileData.IsDirectory)
{
foreach (var child in GetFilteredFileSystemEntries(lpFindFileData.Path, flattenFolderDepth: flattenFolderDepth - 1))
foreach (var child in GetFilteredFileSystemEntries(lpFindFileData.Path, logger, flattenFolderDepth: flattenFolderDepth - 1))
{
dict[child.Key] = child.Value;
}

View File

@ -16,6 +16,7 @@ using MediaBrowser.Controller.Updates;
using MediaBrowser.Controller.Weather;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.System;
using System;
@ -315,8 +316,8 @@ namespace MediaBrowser.Controller
/// <summary>
/// Creates a kernel based on a Data path, which is akin to our current programdata path
/// </summary>
public Kernel(IIsoManager isoManager, IZipClient zipClient, IBlurayExaminer blurayExaminer)
: base(isoManager)
public Kernel(IIsoManager isoManager, IZipClient zipClient, IBlurayExaminer blurayExaminer, ILogger logger)
: base(isoManager, logger)
{
if (isoManager == null)
{

View File

@ -38,7 +38,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="args">The <see cref="ChildrenChangedEventArgs" /> instance containing the event data.</param>
internal void OnLibraryChanged(ChildrenChangedEventArgs args)
{
EventHelper.QueueEventIfNotNull(LibraryChanged, this, args);
EventHelper.QueueEventIfNotNull(LibraryChanged, this, args, Logger);
// Had to put this in a separate method to avoid an implicitly captured closure
SendLibraryChangedWebSocketMessage(args);
@ -115,7 +115,7 @@ namespace MediaBrowser.Controller.Library
// When resolving the root, we need it's grandchildren (children of user views)
var flattenFolderDepth = args.IsPhysicalRoot ? 2 : 0;
args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, flattenFolderDepth: flattenFolderDepth, args: args);
args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, Logger, flattenFolderDepth: flattenFolderDepth, args: args);
}
// Check to see if we should resolve based on our contents

View File

@ -65,7 +65,7 @@ namespace MediaBrowser.Controller.Library
{
Argument = item,
User = user
});
}, Logger);
}
/// <summary>
@ -104,7 +104,7 @@ namespace MediaBrowser.Controller.Library
Argument = item,
User = user,
PlaybackPositionTicks = positionTicks
});
}, Logger);
}
/// <summary>
@ -150,7 +150,7 @@ namespace MediaBrowser.Controller.Library
Argument = item,
User = user,
PlaybackPositionTicks = positionTicks
});
}, Logger);
}
/// <summary>

View File

@ -62,7 +62,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="user">The user.</param>
internal void OnUserUpdated(User user)
{
EventHelper.QueueEventIfNotNull(UserUpdated, this, new GenericEventArgs<User> { Argument = user });
EventHelper.QueueEventIfNotNull(UserUpdated, this, new GenericEventArgs<User> { Argument = user }, Logger);
// Notify connected ui's
Kernel.TcpManager.SendWebSocketMessage("UserUpdated", DtoBuilder.GetDtoUser(user));
@ -80,7 +80,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="user">The user.</param>
internal void OnUserDeleted(User user)
{
EventHelper.QueueEventIfNotNull(UserDeleted, this, new GenericEventArgs<User> { Argument = user });
EventHelper.QueueEventIfNotNull(UserDeleted, this, new GenericEventArgs<User> { Argument = user }, Logger);
// Notify connected ui's
Kernel.TcpManager.SendWebSocketMessage("UserDeleted", user.Id.ToString());

View File

@ -45,7 +45,7 @@ namespace MediaBrowser.Controller.Updates
/// <param name="plugin">The plugin.</param>
private void OnPluginUninstalled(IPlugin plugin)
{
EventHelper.QueueEventIfNotNull(PluginUninstalled, this, new GenericEventArgs<IPlugin> { Argument = plugin });
EventHelper.QueueEventIfNotNull(PluginUninstalled, this, new GenericEventArgs<IPlugin> { Argument = plugin }, Logger);
// Notify connected ui's
Kernel.TcpManager.SendWebSocketMessage("PluginUninstalled", plugin.GetPluginInfo());
@ -66,7 +66,7 @@ namespace MediaBrowser.Controller.Updates
{
Logger.Info("Plugin updated: {0} {1} {2}", newVersion.name, newVersion.version, newVersion.classification);
EventHelper.QueueEventIfNotNull(PluginUpdated, this, new GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>> { Argument = new Tuple<IPlugin, PackageVersionInfo>(plugin, newVersion) });
EventHelper.QueueEventIfNotNull(PluginUpdated, this, new GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>> { Argument = new Tuple<IPlugin, PackageVersionInfo>(plugin, newVersion) }, Logger);
Kernel.NotifyPendingRestart();
}
@ -85,7 +85,7 @@ namespace MediaBrowser.Controller.Updates
{
Logger.Info("New plugin installed: {0} {1} {2}", package.name, package.version, package.classification);
EventHelper.QueueEventIfNotNull(PluginInstalled, this, new GenericEventArgs<PackageVersionInfo> { Argument = package });
EventHelper.QueueEventIfNotNull(PluginInstalled, this, new GenericEventArgs<PackageVersionInfo> { Argument = package }, Logger);
Kernel.NotifyPendingRestart();
}

View File

@ -3,6 +3,7 @@ using MediaBrowser.Common.Logging;
using MediaBrowser.Common.UI;
using MediaBrowser.Controller;
using MediaBrowser.IsoMounter;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Uninstall;
using MediaBrowser.ServerApplication.Implementations;
using System;
@ -24,7 +25,10 @@ namespace MediaBrowser.ServerApplication
[STAThread]
public static void Main()
{
RunApplication<App>("MediaBrowserServer");
var application = new App(LogManager.GetLogger("App"));
application.InitializeComponent();
application.Run();
}
/// <summary>
@ -39,6 +43,16 @@ namespace MediaBrowser.ServerApplication
}
}
/// <summary>
/// Initializes a new instance of the <see cref="App" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
public App(ILogger logger)
: base(logger)
{
}
/// <summary>
/// Gets the name of the product.
/// </summary>
@ -170,7 +184,7 @@ namespace MediaBrowser.ServerApplication
/// <returns>IKernel.</returns>
protected override IKernel InstantiateKernel()
{
return new Kernel(new PismoIsoManager(LogManager.GetLogger("PismoIsoManager")), new DotNetZipClient(), new BdInfoExaminer());
return new Kernel(new PismoIsoManager(Logger), new DotNetZipClient(), new BdInfoExaminer(), Logger);
}
/// <summary>
@ -179,7 +193,7 @@ namespace MediaBrowser.ServerApplication
/// <returns>Window.</returns>
protected override Window InstantiateMainWindow()
{
return new MainWindow(LogManager.GetLogger("MainWindow"));
return new MainWindow(Logger);
}
}
}

View File

@ -160,7 +160,7 @@ namespace MediaBrowser.ServerApplication
// Show the notification
if (newItems.Count == 1)
{
Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new ItemUpdateNotification(LogManager.GetLogger("ItemUpdateNotification"))
Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new ItemUpdateNotification(_logger)
{
DataContext = newItems[0]
@ -168,7 +168,7 @@ namespace MediaBrowser.ServerApplication
}
else if (newItems.Count > 1)
{
Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new MultiItemUpdateNotification(LogManager.GetLogger("ItemUpdateNotification"))
Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new MultiItemUpdateNotification(_logger)
{
DataContext = newItems

View File

@ -7,6 +7,7 @@ using MediaBrowser.Common.UI;
using MediaBrowser.IsoMounter;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Weather;
using MediaBrowser.UI.Controller;
@ -235,16 +236,29 @@ namespace MediaBrowser.UI
[STAThread]
public static void Main()
{
RunApplication<App>("MediaBrowserUI");
var application = new App(LogManager.GetLogger("App"));
application.InitializeComponent();
application.Run();
}
/// <summary>
/// Initializes a new instance of the <see cref="App" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
public App(ILogger logger)
: base(logger)
{
}
/// <summary>
/// Instantiates the kernel.
/// </summary>
/// <returns>IKernel.</returns>
protected override IKernel InstantiateKernel()
{
return new UIKernel(new PismoIsoManager(LogManager.GetLogger("PismoIsoManager")));
return new UIKernel(new PismoIsoManager(Logger), Logger);
}
/// <summary>

View File

@ -3,6 +3,7 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Connectivity;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using MediaBrowser.UI.Configuration;
using MediaBrowser.UI.Playback;
@ -46,8 +47,8 @@ namespace MediaBrowser.UI.Controller
/// <summary>
/// Initializes a new instance of the <see cref="UIKernel" /> class.
/// </summary>
public UIKernel(IIsoManager isoManager)
: base(isoManager)
public UIKernel(IIsoManager isoManager, ILogger logger)
: base(isoManager, logger)
{
Instance = this;
}

View File

@ -31,7 +31,7 @@ namespace MediaBrowser.UI.Playback
public event EventHandler VolumeChanged;
protected void OnVolumeChanged()
{
EventHelper.FireEventIfNotNull(VolumeChanged, this, EventArgs.Empty);
EventHelper.FireEventIfNotNull(VolumeChanged, this, EventArgs.Empty, Logger);
}
#endregion
@ -42,7 +42,7 @@ namespace MediaBrowser.UI.Playback
public event EventHandler PlayStateChanged;
protected void OnPlayStateChanged()
{
EventHelper.FireEventIfNotNull(PlayStateChanged, this, EventArgs.Empty);
EventHelper.FireEventIfNotNull(PlayStateChanged, this, EventArgs.Empty, Logger);
}
#endregion

View File

@ -49,7 +49,7 @@ namespace MediaBrowser.UI.Playback
Options = options,
Player = player,
PlayerConfiguration = playerConfiguration
});
}, Logger);
}
#endregion
@ -70,7 +70,7 @@ namespace MediaBrowser.UI.Playback
{
Items = items,
Player = player
});
}, Logger);
}
#endregion