diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs
index 48a7d62bf..2b2063b55 100644
--- a/MediaBrowser.Common/Kernel/BaseKernel.cs
+++ b/MediaBrowser.Common/Kernel/BaseKernel.cs
@@ -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);
}
///
diff --git a/MediaBrowser.Common/Kernel/BaseManager.cs b/MediaBrowser.Common/Kernel/BaseManager.cs
index 565e4295e..3d830caef 100644
--- a/MediaBrowser.Common/Kernel/BaseManager.cs
+++ b/MediaBrowser.Common/Kernel/BaseManager.cs
@@ -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
///
/// The type of the T kernel type.
public abstract class BaseManager : IDisposable
- where TKernelType : IKernel
+ where TKernelType : class, IKernel
{
- ///
- /// Gets the logger.
- ///
- /// The logger.
- protected ILogger Logger { get; private set; }
-
///
/// The _kernel
///
@@ -33,12 +25,8 @@ namespace MediaBrowser.Common.Kernel
{
throw new ArgumentNullException("kernel");
}
-
+
Kernel = kernel;
-
- Logger = LogManager.GetLogger(GetType().Name);
-
- Logger.Info("Initializing");
}
///
@@ -46,8 +34,6 @@ namespace MediaBrowser.Common.Kernel
///
public void Dispose()
{
- Logger.Info("Disposing");
-
Dispose(true);
GC.SuppressFinalize(this);
}
diff --git a/MediaBrowser.Common/Kernel/TcpManager.cs b/MediaBrowser.Common/Kernel/TcpManager.cs
index 155d3c4a2..7fb624f73 100644
--- a/MediaBrowser.Common/Kernel/TcpManager.cs
+++ b/MediaBrowser.Common/Kernel/TcpManager.cs
@@ -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
/// The external web socket server.
private WebSocketServer ExternalWebSocketServer { get; set; }
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// The _supports native web socket
///
@@ -103,9 +109,12 @@ namespace MediaBrowser.Common.Kernel
/// Initializes a new instance of the class.
///
/// The kernel.
- public TcpManager(IKernel kernel)
+ /// The logger.
+ 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");
}
///
@@ -150,7 +159,7 @@ namespace MediaBrowser.Common.Kernel
/// The context.
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
/// The instance containing the event data.
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 { 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();
diff --git a/MediaBrowser.Common/Net/HttpManager.cs b/MediaBrowser.Common/Net/HttpManager.cs
index 3a87a8951..1deffba69 100644
--- a/MediaBrowser.Common/Net/HttpManager.cs
+++ b/MediaBrowser.Common/Net/HttpManager.cs
@@ -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
///
public class HttpManager : BaseManager
{
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public HttpManager(IKernel kernel)
+ /// The logger.
+ public HttpManager(IKernel kernel, ILogger logger)
: base(kernel)
{
+ _logger = logger;
}
///
@@ -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 };
diff --git a/MediaBrowser.Common/ScheduledTasks/TaskManager.cs b/MediaBrowser.Common/ScheduledTasks/TaskManager.cs
index 4e6407e7c..b71ab8161 100644
--- a/MediaBrowser.Common/ScheduledTasks/TaskManager.cs
+++ b/MediaBrowser.Common/ScheduledTasks/TaskManager.cs
@@ -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
///
private readonly List _taskQueue = new List();
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public TaskManager(IKernel kernel)
+ /// The logger.
+ public TaskManager(IKernel kernel, ILogger logger)
: base(kernel)
{
-
+ _logger = logger;
}
///
@@ -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);
}
}
}
diff --git a/MediaBrowser.Controller/Drawing/ImageManager.cs b/MediaBrowser.Controller/Drawing/ImageManager.cs
index c033fd1f4..2077525a3 100644
--- a/MediaBrowser.Controller/Drawing/ImageManager.cs
+++ b/MediaBrowser.Controller/Drawing/ImageManager.cs
@@ -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
///
private readonly ConcurrentDictionary> _cachedImagedSizes = new ConcurrentDictionary>();
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public ImageManager(Kernel kernel)
+ /// The logger.
+ 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 };
diff --git a/MediaBrowser.Controller/IO/FileSystemManager.cs b/MediaBrowser.Controller/IO/FileSystemManager.cs
index 359a77d60..9b54bb9d8 100644
--- a/MediaBrowser.Controller/IO/FileSystemManager.cs
+++ b/MediaBrowser.Controller/IO/FileSystemManager.cs
@@ -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
/// The directory watchers.
private DirectoryWatchers DirectoryWatchers { get; set; }
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public FileSystemManager(Kernel kernel)
+ /// The logger.
+ public FileSystemManager(Kernel kernel, ILogger logger)
: base(kernel)
{
- DirectoryWatchers = new DirectoryWatchers(Logger);
+ _logger = logger;
+ DirectoryWatchers = new DirectoryWatchers(logger);
}
///
diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs
index c8779dc9d..992809c2f 100644
--- a/MediaBrowser.Controller/Kernel.cs
+++ b/MediaBrowser.Controller/Kernel.cs
@@ -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();
}
diff --git a/MediaBrowser.Controller/Library/LibraryManager.cs b/MediaBrowser.Controller/Library/LibraryManager.cs
index d5b45e211..95a11e8fe 100644
--- a/MediaBrowser.Controller/Library/LibraryManager.cs
+++ b/MediaBrowser.Controller/Library/LibraryManager.cs
@@ -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
/// The instance containing the event data.
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
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public LibraryManager(Kernel kernel)
+ /// The logger.
+ public LibraryManager(Kernel kernel, ILogger logger)
: base(kernel)
{
+ _logger = logger;
}
///
@@ -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");
}
///
@@ -434,7 +442,7 @@ namespace MediaBrowser.Controller.Library
/// Task.
internal async Task ValidateMediaLibrary(IProgress progress, CancellationToken cancellationToken)
{
- Logger.Info("Validating media library");
+ _logger.Info("Validating media library");
await Kernel.RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false);
diff --git a/MediaBrowser.Controller/Library/UserDataManager.cs b/MediaBrowser.Controller/Library/UserDataManager.cs
index c4a012ece..bda5d0383 100644
--- a/MediaBrowser.Controller/Library/UserDataManager.cs
+++ b/MediaBrowser.Controller/Library/UserDataManager.cs
@@ -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 PlaybackStopped;
#endregion
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public UserDataManager(Kernel kernel)
+ /// The logger.
+ public UserDataManager(Kernel kernel, ILogger logger)
: base(kernel)
{
-
+ _logger = logger;
}
///
@@ -65,7 +72,7 @@ namespace MediaBrowser.Controller.Library
{
Argument = item,
User = user
- }, Logger);
+ }, _logger);
}
///
@@ -104,7 +111,7 @@ namespace MediaBrowser.Controller.Library
Argument = item,
User = user,
PlaybackPositionTicks = positionTicks
- }, Logger);
+ }, _logger);
}
///
@@ -150,7 +157,7 @@ namespace MediaBrowser.Controller.Library
Argument = item,
User = user,
PlaybackPositionTicks = positionTicks
- }, Logger);
+ }, _logger);
}
///
diff --git a/MediaBrowser.Controller/Library/UserManager.cs b/MediaBrowser.Controller/Library/UserManager.cs
index 1a9236b42..f9593db0c 100644
--- a/MediaBrowser.Controller/Library/UserManager.cs
+++ b/MediaBrowser.Controller/Library/UserManager.cs
@@ -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); }
}
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public UserManager(Kernel kernel)
+ /// The logger.
+ public UserManager(Kernel kernel, ILogger logger)
: base(kernel)
{
+ _logger = logger;
}
#region UserUpdated Event
@@ -62,7 +70,7 @@ namespace MediaBrowser.Controller.Library
/// The user.
internal void OnUserUpdated(User user)
{
- EventHelper.QueueEventIfNotNull(UserUpdated, this, new GenericEventArgs { Argument = user }, Logger);
+ EventHelper.QueueEventIfNotNull(UserUpdated, this, new GenericEventArgs { Argument = user }, _logger);
// Notify connected ui's
Kernel.TcpManager.SendWebSocketMessage("UserUpdated", DtoBuilder.GetDtoUser(user));
@@ -80,7 +88,7 @@ namespace MediaBrowser.Controller.Library
/// The user.
internal void OnUserDeleted(User user)
{
- EventHelper.QueueEventIfNotNull(UserDeleted, this, new GenericEventArgs { Argument = user }, Logger);
+ EventHelper.QueueEventIfNotNull(UserDeleted, this, new GenericEventArgs { 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;
}
diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
index ad0b3a63f..9bc1ebaa5 100644
--- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
+++ b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
@@ -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
/// The zip client.
private IZipClient ZipClient { get; set; }
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
/// The zip client.
+ /// The logger.
/// zipClient
- 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;
}
diff --git a/MediaBrowser.Controller/Providers/ProviderManager.cs b/MediaBrowser.Controller/Providers/ProviderManager.cs
index 0d5d497e8..c5e70dfae 100644
--- a/MediaBrowser.Controller/Providers/ProviderManager.cs
+++ b/MediaBrowser.Controller/Providers/ProviderManager.cs
@@ -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> _currentlyRunningProviders =
new ConcurrentDictionary>();
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public ProviderManager(Kernel kernel)
+ /// The logger.
+ 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
///
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
diff --git a/MediaBrowser.Controller/Updates/InstallationManager.cs b/MediaBrowser.Controller/Updates/InstallationManager.cs
index e06e937f2..71a5f487b 100644
--- a/MediaBrowser.Controller/Updates/InstallationManager.cs
+++ b/MediaBrowser.Controller/Updates/InstallationManager.cs
@@ -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
/// The plugin.
private void OnPluginUninstalled(IPlugin plugin)
{
- EventHelper.QueueEventIfNotNull(PluginUninstalled, this, new GenericEventArgs { Argument = plugin }, Logger);
+ EventHelper.QueueEventIfNotNull(PluginUninstalled, this, new GenericEventArgs { Argument = plugin }, _logger);
// Notify connected ui's
Kernel.TcpManager.SendWebSocketMessage("PluginUninstalled", plugin.GetPluginInfo());
@@ -64,9 +65,9 @@ namespace MediaBrowser.Controller.Updates
/// The new version.
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> { Argument = new Tuple(plugin, newVersion) }, Logger);
+ EventHelper.QueueEventIfNotNull(PluginUpdated, this, new GenericEventArgs> { Argument = new Tuple(plugin, newVersion) }, _logger);
Kernel.NotifyPendingRestart();
}
@@ -83,9 +84,9 @@ namespace MediaBrowser.Controller.Updates
/// The package.
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 { Argument = package }, Logger);
+ EventHelper.QueueEventIfNotNull(PluginInstalled, this, new GenericEventArgs { Argument = package }, _logger);
Kernel.NotifyPendingRestart();
}
@@ -97,13 +98,19 @@ namespace MediaBrowser.Controller.Updates
/// The zip client.
private IZipClient ZipClient { get; set; }
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
/// The zip client.
+ /// The logger.
/// zipClient
- 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;
}
}
diff --git a/MediaBrowser.UI/Controller/UIKernel.cs b/MediaBrowser.UI/Controller/UIKernel.cs
index 21db41948..e90599934 100644
--- a/MediaBrowser.UI/Controller/UIKernel.cs
+++ b/MediaBrowser.UI/Controller/UIKernel.cs
@@ -144,7 +144,7 @@ namespace MediaBrowser.UI.Controller
/// Task.
protected override Task ReloadInternal()
{
- PlaybackManager = new PlaybackManager(this);
+ PlaybackManager = new PlaybackManager(this, Logger);
return base.ReloadInternal();
}
diff --git a/MediaBrowser.UI/Playback/PlaybackManager.cs b/MediaBrowser.UI/Playback/PlaybackManager.cs
index 86e0773a4..eedcad9b3 100644
--- a/MediaBrowser.UI/Playback/PlaybackManager.cs
+++ b/MediaBrowser.UI/Playback/PlaybackManager.cs
@@ -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
///
public class PlaybackManager : BaseManager
{
+ private readonly ILogger _logger;
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- 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);
}
}