more dependancy injection

This commit is contained in:
LukePulverenti 2013-02-21 16:39:53 -05:00
parent 8f41685a96
commit 931c0ea455
16 changed files with 193 additions and 117 deletions

View File

@ -412,18 +412,18 @@ namespace MediaBrowser.Common.Kernel
Logger.Info("Version {0} initializing", ApplicationVersion);
DisposeHttpManager();
HttpManager = new HttpManager(this);
HttpManager = new HttpManager(this, Logger);
await OnConfigurationLoaded().ConfigureAwait(false);
DisposeTaskManager();
TaskManager = new TaskManager(this);
TaskManager = new TaskManager(this, Logger);
Logger.Info("Loading Plugins");
await ReloadComposableParts().ConfigureAwait(false);
DisposeTcpManager();
TcpManager = new TcpManager(this);
TcpManager = new TcpManager(this, Logger);
}
/// <summary>

View File

@ -1,6 +1,4 @@
using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Logging;
using System;
using System;
namespace MediaBrowser.Common.Kernel
{
@ -9,14 +7,8 @@ namespace MediaBrowser.Common.Kernel
/// </summary>
/// <typeparam name="TKernelType">The type of the T kernel type.</typeparam>
public abstract class BaseManager<TKernelType> : IDisposable
where TKernelType : IKernel
where TKernelType : class, IKernel
{
/// <summary>
/// Gets the logger.
/// </summary>
/// <value>The logger.</value>
protected ILogger Logger { get; private set; }
/// <summary>
/// The _kernel
/// </summary>
@ -35,10 +27,6 @@ namespace MediaBrowser.Common.Kernel
}
Kernel = kernel;
Logger = LogManager.GetLogger(GetType().Name);
Logger.Info("Initializing");
}
/// <summary>
@ -46,8 +34,6 @@ namespace MediaBrowser.Common.Kernel
/// </summary>
public void Dispose()
{
Logger.Info("Disposing");
Dispose(true);
GC.SuppressFinalize(this);
}

View File

@ -3,6 +3,7 @@ using Alchemy.Classes;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Serialization;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -59,6 +60,11 @@ namespace MediaBrowser.Common.Kernel
/// <value>The external web socket server.</value>
private WebSocketServer ExternalWebSocketServer { get; set; }
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// The _supports native web socket
/// </summary>
@ -103,9 +109,12 @@ namespace MediaBrowser.Common.Kernel
/// Initializes a new instance of the <see cref="TcpManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public TcpManager(IKernel kernel)
/// <param name="logger">The logger.</param>
public TcpManager(IKernel kernel, ILogger logger)
: base(kernel)
{
_logger = logger;
if (kernel.IsFirstRun)
{
RegisterServerWithAdministratorAccess();
@ -141,7 +150,7 @@ namespace MediaBrowser.Common.Kernel
ExternalWebSocketServer.Start();
Logger.Info("Alchemy Web Socket Server started");
_logger.Info("Alchemy Web Socket Server started");
}
/// <summary>
@ -150,7 +159,7 @@ namespace MediaBrowser.Common.Kernel
/// <param name="context">The context.</param>
private void OnAlchemyWebSocketClientConnected(UserContext context)
{
var connection = new WebSocketConnection(new AlchemyWebSocket(context, Logger), context.ClientAddress, ProcessWebSocketMessageReceived, Logger);
var connection = new WebSocketConnection(new AlchemyWebSocket(context, _logger), context.ClientAddress, ProcessWebSocketMessageReceived, _logger);
_webSocketConnections.Add(connection);
}
@ -169,15 +178,15 @@ namespace MediaBrowser.Common.Kernel
DisposeHttpServer();
Logger.Info("Loading Http Server");
_logger.Info("Loading Http Server");
try
{
HttpServer = new HttpServer(Kernel.HttpServerUrlPrefix, "Media Browser", Kernel, Logger);
HttpServer = new HttpServer(Kernel.HttpServerUrlPrefix, "Media Browser", Kernel, _logger);
}
catch (HttpListenerException ex)
{
Logger.ErrorException("Error starting Http Server", ex);
_logger.ErrorException("Error starting Http Server", ex);
if (registerServerOnFailure)
{
@ -202,7 +211,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, Logger);
var connection = new WebSocketConnection(e.WebSocket, e.Endpoint, ProcessWebSocketMessageReceived, _logger);
_webSocketConnections.Add(connection);
}
@ -221,7 +230,7 @@ namespace MediaBrowser.Common.Kernel
}
catch (Exception ex)
{
Logger.ErrorException("{0} failed processing WebSocket message {1}", ex, i.GetType().Name, result.MessageType);
_logger.ErrorException("{0} failed processing WebSocket message {1}", ex, i.GetType().Name, result.MessageType);
}
}));
@ -254,7 +263,7 @@ namespace MediaBrowser.Common.Kernel
}
catch (SocketException ex)
{
Logger.ErrorException("Failed to start UDP Server", ex);
_logger.ErrorException("Failed to start UDP Server", ex);
return;
}
@ -265,7 +274,7 @@ namespace MediaBrowser.Common.Kernel
if (expectedMessageBytes.SequenceEqual(res.Buffer))
{
Logger.Info("Received UDP server request from " + res.RemoteEndPoint.ToString());
_logger.Info("Received UDP server request from " + res.RemoteEndPoint.ToString());
// Send a response back with our ip address and port
var response = String.Format("MediaBrowser{0}|{1}:{2}", Kernel.KernelContext, NetUtils.GetLocalIpAddress(), Kernel.UdpServerPortNumber);
@ -330,7 +339,7 @@ namespace MediaBrowser.Common.Kernel
if (connections.Count > 0)
{
Logger.Info("Sending web socket message {0}", messageType);
_logger.Info("Sending web socket message {0}", messageType);
var message = new WebSocketMessage<T> { MessageType = messageType, Data = dataFunction() };
var bytes = JsonSerializer.SerializeToBytes(message);
@ -347,7 +356,7 @@ namespace MediaBrowser.Common.Kernel
}
catch (Exception ex)
{
Logger.ErrorException("Error sending web socket message {0} to {1}", ex, messageType, s.RemoteEndPoint);
_logger.ErrorException("Error sending web socket message {0} to {1}", ex, messageType, s.RemoteEndPoint);
}
}));
@ -386,7 +395,7 @@ namespace MediaBrowser.Common.Kernel
if (HttpServer != null)
{
Logger.Info("Disposing Http Server");
_logger.Info("Disposing Http Server");
HttpServer.WebSocketConnected -= HttpServer_WebSocketConnected;
HttpServer.Dispose();

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using System;
using System.Collections.Concurrent;
@ -20,13 +21,20 @@ namespace MediaBrowser.Common.Net
/// </summary>
public class HttpManager : BaseManager<IKernel>
{
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="HttpManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public HttpManager(IKernel kernel)
/// <param name="logger">The logger.</param>
public HttpManager(IKernel kernel, ILogger logger)
: base(kernel)
{
_logger = logger;
}
/// <summary>
@ -83,7 +91,7 @@ namespace MediaBrowser.Common.Net
await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
Logger.Info("HttpManager.Get url: {0}", url);
_logger.Info("HttpManager.Get url: {0}", url);
try
{
@ -101,7 +109,7 @@ namespace MediaBrowser.Common.Net
}
catch (HttpRequestException ex)
{
Logger.ErrorException("Error getting response from " + url, ex);
_logger.ErrorException("Error getting response from " + url, ex);
throw new HttpException(ex.Message, ex);
}
@ -138,7 +146,7 @@ namespace MediaBrowser.Common.Net
await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
Logger.Info("HttpManager.Post url: {0}", url);
_logger.Info("HttpManager.Post url: {0}", url);
try
{
@ -156,7 +164,7 @@ namespace MediaBrowser.Common.Net
}
catch (HttpRequestException ex)
{
Logger.ErrorException("Error getting response from " + url, ex);
_logger.ErrorException("Error getting response from " + url, ex);
throw new HttpException(ex.Message, ex);
}
@ -199,7 +207,7 @@ namespace MediaBrowser.Common.Net
await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
Logger.Info("HttpManager.FetchToTempFile url: {0}, temp file: {1}", url, tempFile);
_logger.Info("HttpManager.FetchToTempFile url: {0}, temp file: {1}", url, tempFile);
try
{
@ -257,7 +265,7 @@ namespace MediaBrowser.Common.Net
}
catch (HttpRequestException ex)
{
Logger.ErrorException("Error getting response from " + url, ex);
_logger.ErrorException("Error getting response from " + url, ex);
// Cleanup
if (File.Exists(tempFile))
@ -269,7 +277,7 @@ namespace MediaBrowser.Common.Net
}
catch (Exception ex)
{
Logger.ErrorException("Error getting response from " + url, ex);
_logger.ErrorException("Error getting response from " + url, ex);
// Cleanup
if (File.Exists(tempFile))
@ -305,7 +313,7 @@ namespace MediaBrowser.Common.Net
var ms = new MemoryStream();
Logger.Info("HttpManager.FetchToMemoryStream url: {0}", url);
_logger.Info("HttpManager.FetchToMemoryStream url: {0}", url);
try
{
@ -337,7 +345,7 @@ namespace MediaBrowser.Common.Net
}
catch (HttpRequestException ex)
{
Logger.ErrorException("Error getting response from " + url, ex);
_logger.ErrorException("Error getting response from " + url, ex);
ms.Dispose();
@ -345,7 +353,7 @@ namespace MediaBrowser.Common.Net
}
catch (Exception ex)
{
Logger.ErrorException("Error getting response from " + url, ex);
_logger.ErrorException("Error getting response from " + url, ex);
ms.Dispose();
@ -427,7 +435,7 @@ namespace MediaBrowser.Common.Net
{
var msg = string.Format("Connection to {0} timed out", url);
Logger.Error(msg);
_logger.Error(msg);
// Throw an HttpException so that the caller doesn't think it was cancelled by user code
return new HttpException(msg, exception) { IsTimedOut = true };

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using System;
using System.Collections.Generic;
@ -16,14 +17,20 @@ namespace MediaBrowser.Common.ScheduledTasks
/// </summary>
private readonly List<Type> _taskQueue = new List<Type>();
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="TaskManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public TaskManager(IKernel kernel)
/// <param name="logger">The logger.</param>
public TaskManager(IKernel kernel, ILogger logger)
: base(kernel)
{
_logger = logger;
}
/// <summary>
@ -70,12 +77,12 @@ namespace MediaBrowser.Common.ScheduledTasks
if (!_taskQueue.Contains(type))
{
Logger.Info("Queueing task {0}", type.Name);
_logger.Info("Queueing task {0}", type.Name);
_taskQueue.Add(type);
}
else
{
Logger.Info("Task already queued: {0}", type.Name);
_logger.Info("Task already queued: {0}", type.Name);
}
}
}

View File

@ -15,6 +15,7 @@ using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Controller.Drawing
{
@ -51,13 +52,21 @@ namespace MediaBrowser.Controller.Drawing
/// </summary>
private readonly ConcurrentDictionary<string, Task<ImageSize>> _cachedImagedSizes = new ConcurrentDictionary<string, Task<ImageSize>>();
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="ImageManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public ImageManager(Kernel kernel)
/// <param name="logger">The logger.</param>
public ImageManager(Kernel kernel, ILogger logger)
: base(kernel)
{
_logger = logger;
ImageSizeCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "image-sizes"));
ResizedImageCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "resized-images"));
CroppedImageCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "cropped-images"));
@ -103,7 +112,7 @@ namespace MediaBrowser.Controller.Drawing
catch (Exception ex)
{
// We have to have a catch-all here because some of the .net image methods throw a plain old Exception
Logger.ErrorException("Error cropping image", ex);
_logger.ErrorException("Error cropping image", ex);
}
}
@ -121,7 +130,7 @@ namespace MediaBrowser.Controller.Drawing
}
catch
{
Logger.Error("Error enhancing image");
_logger.Error("Error enhancing image");
}
var originalImageSize = await GetImageSize(originalImagePath, dateModified).ConfigureAwait(false);
@ -276,7 +285,7 @@ namespace MediaBrowser.Controller.Drawing
// Cache file doesn't exist no biggie
}
var size = ImageHeader.GetDimensions(imagePath, Logger);
var size = ImageHeader.GetDimensions(imagePath, _logger);
var imageSize = new ImageSize { Width = size.Width, Height = size.Height };

View File

@ -1,6 +1,7 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Logging;
using System;
using System.IO;
using System.Threading;
@ -21,14 +22,21 @@ namespace MediaBrowser.Controller.IO
/// <value>The directory watchers.</value>
private DirectoryWatchers DirectoryWatchers { get; set; }
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public FileSystemManager(Kernel kernel)
/// <param name="logger">The logger.</param>
public FileSystemManager(Kernel kernel, ILogger logger)
: base(kernel)
{
DirectoryWatchers = new DirectoryWatchers(Logger);
_logger = logger;
DirectoryWatchers = new DirectoryWatchers(logger);
}
/// <summary>

View File

@ -364,13 +364,13 @@ namespace MediaBrowser.Controller
RootFolder = null;
ReloadResourcePools();
InstallationManager = new InstallationManager(this, ZipClient);
LibraryManager = new LibraryManager(this);
UserManager = new UserManager(this);
FFMpegManager = new FFMpegManager(this, ZipClient);
ImageManager = new ImageManager(this);
ProviderManager = new ProviderManager(this);
UserDataManager = new UserDataManager(this);
InstallationManager = new InstallationManager(this, ZipClient, Logger);
LibraryManager = new LibraryManager(this, Logger);
UserManager = new UserManager(this, Logger);
FFMpegManager = new FFMpegManager(this, ZipClient, Logger);
ImageManager = new ImageManager(this, Logger);
ProviderManager = new ProviderManager(this, Logger);
UserDataManager = new UserDataManager(this, Logger);
PluginSecurityManager = new PluginSecurityManager(this);
await base.ReloadInternal().ConfigureAwait(false);
@ -489,7 +489,7 @@ namespace MediaBrowser.Controller
{
DisposeFileSystemManager();
FileSystemManager = new FileSystemManager(this);
FileSystemManager = new FileSystemManager(this, Logger);
FileSystemManager.StartWatchers();
}

View File

@ -7,6 +7,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using MoreLinq;
using System;
@ -38,7 +39,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, Logger);
EventHelper.QueueEventIfNotNull(LibraryChanged, this, args, _logger);
// Had to put this in a separate method to avoid an implicitly captured closure
SendLibraryChangedWebSocketMessage(args);
@ -55,13 +56,20 @@ namespace MediaBrowser.Controller.Library
}
#endregion
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="LibraryManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public LibraryManager(Kernel kernel)
/// <param name="logger">The logger.</param>
public LibraryManager(Kernel kernel, ILogger logger)
: base(kernel)
{
_logger = logger;
}
/// <summary>
@ -115,7 +123,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, Logger, 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
@ -155,7 +163,7 @@ namespace MediaBrowser.Controller.Library
}
catch (Exception ex)
{
Logger.ErrorException("Error resolving path {0}", ex, f.Path);
_logger.ErrorException("Error resolving path {0}", ex, f.Path);
}
});
@ -303,7 +311,7 @@ namespace MediaBrowser.Controller.Library
{
cancellationToken.ThrowIfCancellationRequested();
Logger.Debug("Creating {0}: {1}", typeof(T).Name, name);
_logger.Debug("Creating {0}: {1}", typeof(T).Name, name);
path = Path.Combine(path, FileSystem.GetValidFilename(name));
@ -404,7 +412,7 @@ namespace MediaBrowser.Controller.Library
}
catch (IOException ex)
{
Logger.ErrorException("Error validating IBN entry {0}", ex, currentPerson.Name);
_logger.ErrorException("Error validating IBN entry {0}", ex, currentPerson.Name);
}
// Update progress
@ -423,7 +431,7 @@ namespace MediaBrowser.Controller.Library
progress.Report(new TaskProgress { PercentComplete = 100 });
Logger.Info("People validation complete");
_logger.Info("People validation complete");
}
/// <summary>
@ -434,7 +442,7 @@ namespace MediaBrowser.Controller.Library
/// <returns>Task.</returns>
internal async Task ValidateMediaLibrary(IProgress<TaskProgress> progress, CancellationToken cancellationToken)
{
Logger.Info("Validating media library");
_logger.Info("Validating media library");
await Kernel.RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false);

View File

@ -2,6 +2,7 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Connectivity;
using MediaBrowser.Model.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;
@ -28,14 +29,20 @@ namespace MediaBrowser.Controller.Library
public event EventHandler<PlaybackProgressEventArgs> PlaybackStopped;
#endregion
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="UserDataManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public UserDataManager(Kernel kernel)
/// <param name="logger">The logger.</param>
public UserDataManager(Kernel kernel, ILogger logger)
: base(kernel)
{
_logger = logger;
}
/// <summary>
@ -65,7 +72,7 @@ namespace MediaBrowser.Controller.Library
{
Argument = item,
User = user
}, Logger);
}, _logger);
}
/// <summary>
@ -104,7 +111,7 @@ namespace MediaBrowser.Controller.Library
Argument = item,
User = user,
PlaybackPositionTicks = positionTicks
}, Logger);
}, _logger);
}
/// <summary>
@ -150,7 +157,7 @@ namespace MediaBrowser.Controller.Library
Argument = item,
User = user,
PlaybackPositionTicks = positionTicks
}, Logger);
}, _logger);
}
/// <summary>

View File

@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Controller.Library
{
@ -41,13 +42,20 @@ namespace MediaBrowser.Controller.Library
get { return AllConnections.Where(c => (DateTime.UtcNow - c.LastActivityDate).TotalMinutes <= 10); }
}
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="UserManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public UserManager(Kernel kernel)
/// <param name="logger">The logger.</param>
public UserManager(Kernel kernel, ILogger logger)
: base(kernel)
{
_logger = logger;
}
#region UserUpdated Event
@ -62,7 +70,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 }, Logger);
EventHelper.QueueEventIfNotNull(UserUpdated, this, new GenericEventArgs<User> { Argument = user }, _logger);
// Notify connected ui's
Kernel.TcpManager.SendWebSocketMessage("UserUpdated", DtoBuilder.GetDtoUser(user));
@ -80,7 +88,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 }, Logger);
EventHelper.QueueEventIfNotNull(UserDeleted, this, new GenericEventArgs<User> { Argument = user }, _logger);
// Notify connected ui's
Kernel.TcpManager.SendWebSocketMessage("UserDeleted", user.Id.ToString());
@ -113,7 +121,7 @@ namespace MediaBrowser.Controller.Library
await UpdateUser(user).ConfigureAwait(false);
}
Logger.Info("Authentication request for {0} {1}.", user.Name, (success ? "has succeeded" : "has been denied"));
_logger.Info("Authentication request for {0} {1}.", user.Name, (success ? "has succeeded" : "has been denied"));
return success;
}

View File

@ -17,6 +17,7 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Controller.MediaInfo
{
@ -65,13 +66,19 @@ namespace MediaBrowser.Controller.MediaInfo
/// <value>The zip client.</value>
private IZipClient ZipClient { get; set; }
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="FFMpegManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="zipClient">The zip client.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">zipClient</exception>
public FFMpegManager(Kernel kernel, IZipClient zipClient)
public FFMpegManager(Kernel kernel, IZipClient zipClient, ILogger logger)
: base(kernel)
{
if (zipClient == null)
@ -79,6 +86,7 @@ namespace MediaBrowser.Controller.MediaInfo
throw new ArgumentNullException("zipClient");
}
_logger = logger;
ZipClient = zipClient;
// Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
@ -150,7 +158,7 @@ namespace MediaBrowser.Controller.MediaInfo
}
catch (Exception ex)
{
Logger.ErrorException("Error creating chapter images for {0}", ex, video.Name);
_logger.ErrorException("Error creating chapter images for {0}", ex, video.Name);
}
}
}
@ -483,7 +491,7 @@ namespace MediaBrowser.Controller.MediaInfo
EnableRaisingEvents = true
};
Logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
_logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
process.Exited += ProcessExited;
@ -524,11 +532,11 @@ namespace MediaBrowser.Controller.MediaInfo
}
catch (InvalidOperationException ex1)
{
Logger.ErrorException("Error killing ffprobe", ex1);
_logger.ErrorException("Error killing ffprobe", ex1);
}
catch (Win32Exception ex1)
{
Logger.ErrorException("Error killing ffprobe", ex1);
_logger.ErrorException("Error killing ffprobe", ex1);
}
throw;
@ -727,7 +735,7 @@ namespace MediaBrowser.Controller.MediaInfo
return true;
}
Logger.Error("ffmpeg audio image extraction failed for {0}", input.Path);
_logger.Error("ffmpeg audio image extraction failed for {0}", input.Path);
return false;
}
@ -789,7 +797,7 @@ namespace MediaBrowser.Controller.MediaInfo
}
};
Logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
_logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
@ -806,7 +814,7 @@ namespace MediaBrowser.Controller.MediaInfo
return true;
}
Logger.Error("ffmpeg subtitle extraction failed for {0}", input.Path);
_logger.Error("ffmpeg subtitle extraction failed for {0}", input.Path);
return false;
}
@ -844,7 +852,7 @@ namespace MediaBrowser.Controller.MediaInfo
}
};
Logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
_logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
@ -861,7 +869,7 @@ namespace MediaBrowser.Controller.MediaInfo
return true;
}
Logger.Error("ffmpeg subtitle conversion failed for {0}", mediaStream.Path);
_logger.Error("ffmpeg subtitle conversion failed for {0}", mediaStream.Path);
return false;
}
@ -909,22 +917,22 @@ namespace MediaBrowser.Controller.MediaInfo
{
try
{
Logger.Info("Killing ffmpeg process");
_logger.Info("Killing ffmpeg process");
process.Kill();
process.WaitForExit(1000);
}
catch (Win32Exception ex)
{
Logger.ErrorException("Error killing process", ex);
_logger.ErrorException("Error killing process", ex);
}
catch (InvalidOperationException ex)
{
Logger.ErrorException("Error killing process", ex);
_logger.ErrorException("Error killing process", ex);
}
catch (NotSupportedException ex)
{
Logger.ErrorException("Error killing process", ex);
_logger.ErrorException("Error killing process", ex);
}
}
@ -940,12 +948,12 @@ namespace MediaBrowser.Controller.MediaInfo
{
try
{
Logger.Info("Deleting extracted image due to failure: ", outputPath);
_logger.Info("Deleting extracted image due to failure: ", outputPath);
File.Delete(outputPath);
}
catch (IOException ex)
{
Logger.ErrorException("Error deleting extracted image {0}", ex, outputPath);
_logger.ErrorException("Error deleting extracted image {0}", ex, outputPath);
}
}
}
@ -957,7 +965,7 @@ namespace MediaBrowser.Controller.MediaInfo
}
}
Logger.Error("ffmpeg video image extraction failed for {0}", inputPath);
_logger.Error("ffmpeg video image extraction failed for {0}", inputPath);
return false;
}

View File

@ -2,7 +2,7 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@ -29,13 +29,20 @@ namespace MediaBrowser.Controller.Providers
private readonly ConcurrentDictionary<string, Tuple<BaseMetadataProvider, BaseItem, CancellationTokenSource>> _currentlyRunningProviders =
new ConcurrentDictionary<string, Tuple<BaseMetadataProvider, BaseItem, CancellationTokenSource>>();
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="ProviderManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public ProviderManager(Kernel kernel)
/// <param name="logger">The logger.</param>
public ProviderManager(Kernel kernel, ILogger logger)
: base(kernel)
{
_logger = logger;
_remoteImageCache = new FileSystemRepository(ImagesDataPath);
}
@ -118,7 +125,7 @@ namespace MediaBrowser.Controller.Providers
// If providers have changed, clear provider info and update the supported providers hash
if (providersChanged)
{
Logger.Debug("Providers changed for {0}. Clearing and forcing refresh.", item.Name);
_logger.Debug("Providers changed for {0}. Clearing and forcing refresh.", item.Name);
item.ProviderData.Clear();
supportedProvidersInfo.FileSystemStamp = supportedProvidersHash;
}
@ -233,7 +240,7 @@ namespace MediaBrowser.Controller.Providers
/// </summary>
internal void ValidateCurrentlyRunningProviders()
{
Logger.Info("Validing currently running providers");
_logger.Info("Validing currently running providers");
var enableInternetProviders = Kernel.Configuration.EnableInternetProviders;
var internetProviderExcludeTypes = Kernel.Configuration.InternetProviderExcludeTypes;
@ -303,7 +310,7 @@ namespace MediaBrowser.Controller.Providers
}
catch (Exception e)
{
Logger.ErrorException("Error downloading and saving image " + localPath, e);
_logger.ErrorException("Error downloading and saving image " + localPath, e);
throw;
}
finally

View File

@ -6,6 +6,7 @@ using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Progress;
using MediaBrowser.Common.Serialization;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Updates;
using System;
using System.Collections.Concurrent;
@ -45,7 +46,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 }, Logger);
EventHelper.QueueEventIfNotNull(PluginUninstalled, this, new GenericEventArgs<IPlugin> { Argument = plugin }, _logger);
// Notify connected ui's
Kernel.TcpManager.SendWebSocketMessage("PluginUninstalled", plugin.GetPluginInfo());
@ -64,9 +65,9 @@ namespace MediaBrowser.Controller.Updates
/// <param name="newVersion">The new version.</param>
public void OnPluginUpdated(IPlugin plugin, PackageVersionInfo newVersion)
{
Logger.Info("Plugin updated: {0} {1} {2}", newVersion.name, newVersion.version, newVersion.classification);
_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) }, Logger);
EventHelper.QueueEventIfNotNull(PluginUpdated, this, new GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>> { Argument = new Tuple<IPlugin, PackageVersionInfo>(plugin, newVersion) }, _logger);
Kernel.NotifyPendingRestart();
}
@ -83,9 +84,9 @@ namespace MediaBrowser.Controller.Updates
/// <param name="package">The package.</param>
public void OnPluginInstalled(PackageVersionInfo package)
{
Logger.Info("New plugin installed: {0} {1} {2}", package.name, package.version, package.classification);
_logger.Info("New plugin installed: {0} {1} {2}", package.name, package.version, package.classification);
EventHelper.QueueEventIfNotNull(PluginInstalled, this, new GenericEventArgs<PackageVersionInfo> { Argument = package }, Logger);
EventHelper.QueueEventIfNotNull(PluginInstalled, this, new GenericEventArgs<PackageVersionInfo> { Argument = package }, _logger);
Kernel.NotifyPendingRestart();
}
@ -97,13 +98,19 @@ namespace MediaBrowser.Controller.Updates
/// <value>The zip client.</value>
private IZipClient ZipClient { get; set; }
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="InstallationManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="zipClient">The zip client.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">zipClient</exception>
public InstallationManager(Kernel kernel, IZipClient zipClient)
public InstallationManager(Kernel kernel, IZipClient zipClient, ILogger logger)
: base(kernel)
{
if (zipClient == null)
@ -111,6 +118,7 @@ namespace MediaBrowser.Controller.Updates
throw new ArgumentNullException("zipClient");
}
_logger = logger;
ZipClient = zipClient;
}
@ -338,7 +346,7 @@ namespace MediaBrowser.Controller.Updates
CurrentInstallations.Remove(tuple);
}
Logger.Info("Package installation cancelled: {0} {1}", package.name, package.versionStr);
_logger.Info("Package installation cancelled: {0} {1}", package.name, package.versionStr);
Kernel.TcpManager.SendWebSocketMessage("PackageInstallationCancelled", installationInfo);
@ -408,7 +416,7 @@ namespace MediaBrowser.Controller.Updates
}
catch (IOException e)
{
Logger.ErrorException("Error attempting to extract archive from {0} to {1}", e, tempFile, target);
_logger.ErrorException("Error attempting to extract archive from {0} to {1}", e, tempFile, target);
throw;
}
@ -422,7 +430,7 @@ namespace MediaBrowser.Controller.Updates
}
catch (IOException e)
{
Logger.ErrorException("Error attempting to move file from {0} to {1}", e, tempFile, target);
_logger.ErrorException("Error attempting to move file from {0} to {1}", e, tempFile, target);
throw;
}
}

View File

@ -144,7 +144,7 @@ namespace MediaBrowser.UI.Controller
/// <returns>Task.</returns>
protected override Task ReloadInternal()
{
PlaybackManager = new PlaybackManager(this);
PlaybackManager = new PlaybackManager(this, Logger);
return base.ReloadInternal();
}

View File

@ -3,6 +3,7 @@ using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using MediaBrowser.UI.Configuration;
using MediaBrowser.UI.Controller;
@ -20,14 +21,16 @@ namespace MediaBrowser.UI.Playback
/// </summary>
public class PlaybackManager : BaseManager<UIKernel>
{
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="PlaybackManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public PlaybackManager(UIKernel kernel)
public PlaybackManager(UIKernel kernel, ILogger logger)
: base(kernel)
{
_logger = logger;
}
#region PlaybackStarted Event
@ -49,7 +52,7 @@ namespace MediaBrowser.UI.Playback
Options = options,
Player = player,
PlayerConfiguration = playerConfiguration
}, Logger);
}, _logger);
}
#endregion
@ -70,7 +73,7 @@ namespace MediaBrowser.UI.Playback
{
Items = items,
Player = player
}, Logger);
}, _logger);
}
#endregion
@ -154,7 +157,7 @@ namespace MediaBrowser.UI.Playback
}
catch (HttpException ex)
{
Logger.ErrorException("Error retrieving intros", ex);
_logger.ErrorException("Error retrieving intros", ex);
}
}