removed static logger

This commit is contained in:
LukePulverenti 2013-02-21 15:26:35 -05:00
parent 4019b9260b
commit ab1065a567
46 changed files with 424 additions and 211 deletions

View file

@ -6,6 +6,7 @@ using System.ComponentModel.Composition;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Common.Api.Logging namespace MediaBrowser.Common.Api.Logging
{ {
@ -24,6 +25,17 @@ namespace MediaBrowser.Common.Api.Logging
get { return "LogFile"; } get { return "LogFile"; }
} }
/// <summary>
/// Initializes a new instance of the <see cref="LogFileWebSocketListener" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
public LogFileWebSocketListener([Import("logger")] ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Initializes the specified kernel. /// Initializes the specified kernel.
/// </summary> /// </summary>

View file

@ -1,5 +1,6 @@
using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks; using MediaBrowser.Model.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
@ -23,6 +24,17 @@ namespace MediaBrowser.Common.Api.ScheduledTasks
get { return "ScheduledTasksInfo"; } get { return "ScheduledTasksInfo"; }
} }
/// <summary>
/// Initializes a new instance of the <see cref="ScheduledTasksWebSocketListener" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
public ScheduledTasksWebSocketListener([Import("logger")] ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Gets the data to send. /// Gets the data to send.
/// </summary> /// </summary>

View file

@ -1,4 +1,5 @@
using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Logging;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -19,6 +20,17 @@ namespace MediaBrowser.Common.Api
get { return "SystemInfo"; } get { return "SystemInfo"; }
} }
/// <summary>
/// Initializes a new instance of the <see cref="SystemInfoWebSocketListener" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
public SystemInfoWebSocketListener([Import("logger")] ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Gets the data to send. /// Gets the data to send.
/// </summary> /// </summary>

View file

@ -1,4 +1,5 @@
using MediaBrowser.Common.Logging; using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Logging;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -9,6 +10,11 @@ namespace MediaBrowser.Common.Events
/// </summary> /// </summary>
public static class EventHelper public static class EventHelper
{ {
/// <summary>
/// The logger
/// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("EventHelper");
/// <summary> /// <summary>
/// Fires the event. /// Fires the event.
/// </summary> /// </summary>
@ -27,7 +33,7 @@ namespace MediaBrowser.Common.Events
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogException("Error in event handler", ex); Logger.ErrorException("Error in event handler", ex);
} }
}); });
} }
@ -52,7 +58,7 @@ namespace MediaBrowser.Common.Events
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogException("Error in event handler", ex); Logger.ErrorException("Error in event handler", ex);
} }
}); });
} }
@ -74,7 +80,7 @@ namespace MediaBrowser.Common.Events
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogException("Error in event handler", ex); Logger.ErrorException("Error in event handler", ex);
} }
} }
} }
@ -96,7 +102,7 @@ namespace MediaBrowser.Common.Events
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogException("Error in event handler", ex); Logger.ErrorException("Error in event handler", ex);
} }
} }
} }

View file

@ -38,8 +38,6 @@ namespace MediaBrowser.Common.IO
{ {
if (!path.EndsWith("*", StringComparison.OrdinalIgnoreCase)) if (!path.EndsWith("*", StringComparison.OrdinalIgnoreCase))
{ {
Logger.LogInfo("Handle came back invalid for {0}. This might be a network share. Since this is a directory we'll try appending " + Path.DirectorySeparatorChar + "*.", path);
NativeMethods.FindClose(handle); NativeMethods.FindClose(handle);
handle = NativeMethods.FindFirstFileEx(Path.Combine(path, "*"), FINDEX_INFO_LEVELS.FindExInfoBasic, out data, handle = NativeMethods.FindFirstFileEx(Path.Combine(path, "*"), FINDEX_INFO_LEVELS.FindExInfoBasic, out data,

View file

@ -143,7 +143,7 @@ namespace MediaBrowser.Common.Kernel
get get
{ {
// Lazy load // Lazy load
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationLoaded, ref _configurationSyncLock, () => XmlSerializer.GetXmlConfiguration<TConfigurationType>(ApplicationPaths.SystemConfigurationFilePath)); LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationLoaded, ref _configurationSyncLock, () => XmlSerializer.GetXmlConfiguration<TConfigurationType>(ApplicationPaths.SystemConfigurationFilePath, Logger));
return _configuration; return _configuration;
} }
protected set protected set
@ -441,8 +441,6 @@ namespace MediaBrowser.Common.Kernel
AddLogTarget(logFile, "ApplicationLogFile"); AddLogTarget(logFile, "ApplicationLogFile");
Logging.Logger.LoggerInstance = Logging.LogManager.GetLogger("App");
OnLoggerLoaded(); OnLoggerLoaded();
} }
@ -590,7 +588,7 @@ namespace MediaBrowser.Common.Kernel
try try
{ {
plugin.Initialize(this); plugin.Initialize(this, Logging.LogManager.GetLogger(plugin.GetType().Name));
Logger.Info("{0} {1} initialized.", plugin.Name, plugin.Version); Logger.Info("{0} {1} initialized.", plugin.Name, plugin.Version);
} }

View file

@ -6,6 +6,7 @@ using System.Linq;
using System.Net.WebSockets; using System.Net.WebSockets;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Common.Kernel namespace MediaBrowser.Common.Kernel
{ {
@ -38,6 +39,25 @@ namespace MediaBrowser.Common.Kernel
/// <returns>Task{`1}.</returns> /// <returns>Task{`1}.</returns>
protected abstract Task<TReturnDataType> GetDataToSend(TStateType state); protected abstract Task<TReturnDataType> GetDataToSend(TStateType state);
/// <summary>
/// The logger
/// </summary>
protected ILogger Logger;
/// <summary>
/// Initializes a new instance of the <see cref="BasePeriodicWebSocketListener{TStateType}" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
protected BasePeriodicWebSocketListener(ILogger logger)
{
if (logger == null)
{
throw new ArgumentNullException("logger");
}
Logger = logger;
}
/// <summary> /// <summary>
/// Processes the message internal. /// Processes the message internal.
/// </summary> /// </summary>
@ -71,7 +91,7 @@ namespace MediaBrowser.Common.Kernel
var cancellationTokenSource = new CancellationTokenSource(); var cancellationTokenSource = new CancellationTokenSource();
Logger.LogInfo("{1} Begin transmitting over websocket to {0}", message.Connection.RemoteEndPoint, GetType().Name); Logger.Info("{1} Begin transmitting over websocket to {0}", message.Connection.RemoteEndPoint, GetType().Name);
var timer = new Timer(TimerCallback, message.Connection, Timeout.Infinite, Timeout.Infinite); var timer = new Timer(TimerCallback, message.Connection, Timeout.Infinite, Timeout.Infinite);
@ -135,7 +155,7 @@ namespace MediaBrowser.Common.Kernel
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogException("Error sending web socket message {0}", ex, Name); Logger.ErrorException("Error sending web socket message {0}", ex, Name);
DisposeConnection(tuple); DisposeConnection(tuple);
} }
finally finally
@ -167,7 +187,7 @@ namespace MediaBrowser.Common.Kernel
/// <param name="connection">The connection.</param> /// <param name="connection">The connection.</param>
private void DisposeConnection(Tuple<WebSocketConnection, CancellationTokenSource, Timer, TStateType, SemaphoreSlim> connection) private void DisposeConnection(Tuple<WebSocketConnection, CancellationTokenSource, Timer, TStateType, SemaphoreSlim> connection)
{ {
Logger.LogInfo("{1} stop transmitting over websocket to {0}", connection.Item1.RemoteEndPoint, GetType().Name); Logger.Info("{1} stop transmitting over websocket to {0}", connection.Item1.RemoteEndPoint, GetType().Name);
try try
{ {

View file

@ -1,89 +0,0 @@
using MediaBrowser.Model.Logging;
using System;
namespace MediaBrowser.Common.Logging
{
/// <summary>
/// Class Logger
/// </summary>
public static class Logger
{
/// <summary>
/// Gets or sets the logger instance.
/// </summary>
/// <value>The logger instance.</value>
internal static ILogger LoggerInstance { get; set; }
/// <summary>
/// Logs the info.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="paramList">The param list.</param>
public static void LogInfo(string message, params object[] paramList)
{
LogEntry(message, LogSeverity.Info, null, paramList);
}
/// <summary>
/// Logs the debug info.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="paramList">The param list.</param>
public static void LogDebugInfo(string message, params object[] paramList)
{
LogEntry(message, LogSeverity.Debug, null, paramList);
}
/// <summary>
/// Logs the exception.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="ex">The ex.</param>
/// <param name="paramList">The param list.</param>
public static void LogException(string message, Exception ex, params object[] paramList)
{
LogEntry(message, LogSeverity.Error, ex, paramList);
}
/// <summary>
/// Logs the warning.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="paramList">The param list.</param>
public static void LogWarning(string message, params object[] paramList)
{
LogEntry(message, LogSeverity.Warn, null, paramList);
}
/// <summary>
/// Logs the entry.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="level">The level.</param>
/// <param name="exception">The exception.</param>
/// <param name="paramList">The param list.</param>
private static void LogEntry(string message, LogSeverity level, Exception exception, params object[] paramList)
{
if (LoggerInstance == null)
{
return;
}
if (exception == null)
{
LoggerInstance.Log(level, message, paramList);
}
else
{
if (level == LogSeverity.Fatal)
{
LoggerInstance.FatalException(message, exception, paramList);
}
else
{
LoggerInstance.ErrorException(message, exception, paramList);
}
}
}
}
}

View file

@ -187,7 +187,6 @@
<Compile Include="Serialization\JsonSerializer.cs" /> <Compile Include="Serialization\JsonSerializer.cs" />
<Compile Include="Kernel\BaseKernel.cs" /> <Compile Include="Kernel\BaseKernel.cs" />
<Compile Include="Kernel\KernelContext.cs" /> <Compile Include="Kernel\KernelContext.cs" />
<Compile Include="Logging\Logger.cs" />
<Compile Include="Net\Handlers\BaseHandler.cs" /> <Compile Include="Net\Handlers\BaseHandler.cs" />
<Compile Include="Net\Handlers\BaseSerializationHandler.cs" /> <Compile Include="Net\Handlers\BaseSerializationHandler.cs" />
<Compile Include="Net\HttpServer.cs" /> <Compile Include="Net\HttpServer.cs" />

View file

@ -189,7 +189,7 @@ namespace MediaBrowser.Common.Plugins
get get
{ {
// Lazy load // Lazy load
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => XmlSerializer.GetXmlConfiguration(ConfigurationType, ConfigurationFilePath) as TConfigurationType); LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => XmlSerializer.GetXmlConfiguration(ConfigurationType, ConfigurationFilePath, Logger) as TConfigurationType);
return _configuration; return _configuration;
} }
protected set protected set
@ -274,15 +274,21 @@ namespace MediaBrowser.Common.Plugins
/// Starts the plugin. /// Starts the plugin.
/// </summary> /// </summary>
/// <param name="kernel">The kernel.</param> /// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">kernel</exception> /// <exception cref="System.ArgumentNullException">kernel</exception>
public void Initialize(IKernel kernel) public void Initialize(IKernel kernel, ILogger logger)
{ {
if (kernel == null) if (kernel == null)
{ {
throw new ArgumentNullException("kernel"); throw new ArgumentNullException("kernel");
} }
Logger = LogManager.GetLogger(Name); if (logger == null)
{
throw new ArgumentNullException("logger");
}
Logger = logger;
Kernel = kernel; Kernel = kernel;

View file

@ -107,8 +107,9 @@ namespace MediaBrowser.Common.Plugins
/// Starts the plugin. /// Starts the plugin.
/// </summary> /// </summary>
/// <param name="kernel">The kernel.</param> /// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">kernel</exception> /// <exception cref="System.ArgumentNullException">kernel</exception>
void Initialize(IKernel kernel); void Initialize(IKernel kernel, ILogger logger);
/// <summary> /// <summary>
/// Disposes the plugins. Undos all actions performed during Init. /// Disposes the plugins. Undos all actions performed during Init.

View file

@ -3,6 +3,7 @@ using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Common.Serialization namespace MediaBrowser.Common.Serialization
{ {
@ -157,10 +158,11 @@ namespace MediaBrowser.Common.Serialization
/// </summary> /// </summary>
/// <param name="type">The type.</param> /// <param name="type">The type.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="logger">The logger.</param>
/// <returns>System.Object.</returns> /// <returns>System.Object.</returns>
public static object GetXmlConfiguration(Type type, string path) public static object GetXmlConfiguration(Type type, string path, ILogger logger)
{ {
Logger.LogInfo("Loading {0} at {1}", type.Name, path); logger.Info("Loading {0} at {1}", type.Name, path);
object configuration; object configuration;
@ -184,7 +186,7 @@ namespace MediaBrowser.Common.Serialization
// If the file didn't exist before, or if something has changed, re-save // If the file didn't exist before, or if something has changed, re-save
if (buffer == null || !buffer.SequenceEqual(newBytes)) if (buffer == null || !buffer.SequenceEqual(newBytes))
{ {
Logger.LogInfo("Saving {0} to {1}", type.Name, path); logger.Info("Saving {0} to {1}", type.Name, path);
// Save it after load in case we got new items // Save it after load in case we got new items
File.WriteAllBytes(path, newBytes); File.WriteAllBytes(path, newBytes);
@ -200,11 +202,12 @@ namespace MediaBrowser.Common.Serialization
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="logger">The logger.</param>
/// <returns>``0.</returns> /// <returns>``0.</returns>
public static T GetXmlConfiguration<T>(string path) public static T GetXmlConfiguration<T>(string path, ILogger logger)
where T : class where T : class
{ {
return GetXmlConfiguration(typeof(T), path) as T; return GetXmlConfiguration(typeof(T), path, logger) as T;
} }
} }
} }

View file

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Controller.Drawing namespace MediaBrowser.Controller.Drawing
{ {
@ -36,9 +37,10 @@ namespace MediaBrowser.Controller.Drawing
/// Gets the dimensions of an image. /// Gets the dimensions of an image.
/// </summary> /// </summary>
/// <param name="path">The path of the image to get the dimensions of.</param> /// <param name="path">The path of the image to get the dimensions of.</param>
/// <param name="logger">The logger.</param>
/// <returns>The dimensions of the specified image.</returns> /// <returns>The dimensions of the specified image.</returns>
/// <exception cref="ArgumentException">The image was of an unrecognised format.</exception> /// <exception cref="ArgumentException">The image was of an unrecognised format.</exception>
public static Size GetDimensions(string path) public static Size GetDimensions(string path, ILogger logger)
{ {
try try
{ {
@ -52,7 +54,7 @@ namespace MediaBrowser.Controller.Drawing
} }
catch catch
{ {
Logger.LogInfo("Failed to read image header for {0}. Doing it the slow way.", path); logger.Info("Failed to read image header for {0}. Doing it the slow way.", path);
using (var fs = File.OpenRead(path)) using (var fs = File.OpenRead(path))
{ {

View file

@ -276,7 +276,7 @@ namespace MediaBrowser.Controller.Drawing
// Cache file doesn't exist no biggie // Cache file doesn't exist no biggie
} }
var size = ImageHeader.GetDimensions(imagePath); var size = ImageHeader.GetDimensions(imagePath, Logger);
var imageSize = new ImageSize { Width = size.Width, Height = size.Height }; var imageSize = new ImageSize { Width = size.Width, Height = size.Height };

View file

@ -16,6 +16,7 @@ using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Controller.Entities namespace MediaBrowser.Controller.Entities
{ {
@ -93,6 +94,11 @@ namespace MediaBrowser.Controller.Entities
/// <value>The date modified.</value> /// <value>The date modified.</value>
public DateTime DateModified { get; set; } public DateTime DateModified { get; set; }
/// <summary>
/// The logger
/// </summary>
protected static ILogger Logger = LogManager.GetLogger("BaseItem");
/// <summary> /// <summary>
/// Returns a <see cref="System.String" /> that represents this instance. /// Returns a <see cref="System.String" /> that represents this instance.
/// </summary> /// </summary>
@ -268,7 +274,7 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error creating resolve args for ", ex, Path); Logger.ErrorException("Error creating resolve args for ", ex, Path);
throw; throw;
} }
@ -581,7 +587,7 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path); Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
return new List<Video> { }; return new List<Video> { };
} }
@ -606,7 +612,7 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error loading trailers for {0}", ex, Name); Logger.ErrorException("Error loading trailers for {0}", ex, Name);
return new List<Video> { }; return new List<Video> { };
} }
@ -975,7 +981,7 @@ namespace MediaBrowser.Controller.Entities
var changed = copy.DateModified != DateModified; var changed = copy.DateModified != DateModified;
if (changed) if (changed)
{ {
Logger.LogDebugInfo(Name + " changed - original creation: " + DateCreated + " new creation: " + copy.DateCreated + " original modified: " + DateModified + " new modified: " + copy.DateModified); Logger.Debug(Name + " changed - original creation: " + DateCreated + " new creation: " + copy.DateCreated + " original modified: " + DateModified + " new modified: " + copy.DateModified);
} }
return changed; return changed;
} }

View file

@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error creating FolderIds for {0}", ex, Path); Logger.ErrorException("Error creating FolderIds for {0}", ex, Path);
folderIds = new Guid[] {}; folderIds = new Guid[] {};
} }

View file

@ -306,7 +306,7 @@ namespace MediaBrowser.Controller.Entities
// Even though this implementation means multiple iterations over the target list - it allows us to defer // Even though this implementation means multiple iterations over the target list - it allows us to defer
// the retrieval of the individual children for each index value until they are requested. // the retrieval of the individual children for each index value until they are requested.
using (new Profiler(indexName + " Index Build for " + Name)) using (new Profiler(indexName + " Index Build for " + Name, Logger))
{ {
// Put this in a local variable to avoid an implicitly captured closure // Put this in a local variable to avoid an implicitly captured closure
var currentIndexName = indexName; var currentIndexName = indexName;
@ -325,12 +325,12 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error getting person {0}", ex, i); Logger.ErrorException("Error getting person {0}", ex, i);
return null; return null;
} }
catch (AggregateException ex) catch (AggregateException ex)
{ {
Logger.LogException("Error getting person {0}", ex, i); Logger.ErrorException("Error getting person {0}", ex, i);
return null; return null;
} }
}) })
@ -351,7 +351,7 @@ namespace MediaBrowser.Controller.Entities
{ {
// Even though this implementation means multiple iterations over the target list - it allows us to defer // Even though this implementation means multiple iterations over the target list - it allows us to defer
// the retrieval of the individual children for each index value until they are requested. // the retrieval of the individual children for each index value until they are requested.
using (new Profiler("Studio Index Build for " + Name)) using (new Profiler("Studio Index Build for " + Name, Logger))
{ {
var indexName = LocalizedStrings.Instance.GetString("StudioDispPref"); var indexName = LocalizedStrings.Instance.GetString("StudioDispPref");
@ -367,12 +367,12 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error getting studio {0}", ex, i); Logger.ErrorException("Error getting studio {0}", ex, i);
return null; return null;
} }
catch (AggregateException ex) catch (AggregateException ex)
{ {
Logger.LogException("Error getting studio {0}", ex, i); Logger.ErrorException("Error getting studio {0}", ex, i);
return null; return null;
} }
}) })
@ -390,7 +390,7 @@ namespace MediaBrowser.Controller.Entities
{ {
// Even though this implementation means multiple iterations over the target list - it allows us to defer // Even though this implementation means multiple iterations over the target list - it allows us to defer
// the retrieval of the individual children for each index value until they are requested. // the retrieval of the individual children for each index value until they are requested.
using (new Profiler("Genre Index Build for " + Name)) using (new Profiler("Genre Index Build for " + Name, Logger))
{ {
var indexName = LocalizedStrings.Instance.GetString("GenreDispPref"); var indexName = LocalizedStrings.Instance.GetString("GenreDispPref");
@ -407,12 +407,12 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error getting genre {0}", ex, i); Logger.ErrorException("Error getting genre {0}", ex, i);
return null; return null;
} }
catch (AggregateException ex) catch (AggregateException ex)
{ {
Logger.LogException("Error getting genre {0}", ex, i); Logger.ErrorException("Error getting genre {0}", ex, i);
return null; return null;
} }
}) })
@ -431,7 +431,7 @@ namespace MediaBrowser.Controller.Entities
{ {
// Even though this implementation means multiple iterations over the target list - it allows us to defer // Even though this implementation means multiple iterations over the target list - it allows us to defer
// the retrieval of the individual children for each index value until they are requested. // the retrieval of the individual children for each index value until they are requested.
using (new Profiler("Production Year Index Build for " + Name)) using (new Profiler("Production Year Index Build for " + Name, Logger))
{ {
var indexName = LocalizedStrings.Instance.GetString("YearDispPref"); var indexName = LocalizedStrings.Instance.GetString("YearDispPref");
@ -448,12 +448,12 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error getting year {0}", ex, i); Logger.ErrorException("Error getting year {0}", ex, i);
return null; return null;
} }
catch (AggregateException ex) catch (AggregateException ex)
{ {
Logger.LogException("Error getting year {0}", ex, i); Logger.ErrorException("Error getting year {0}", ex, i);
return null; return null;
} }
}) })
@ -639,7 +639,7 @@ namespace MediaBrowser.Controller.Entities
} }
catch (OperationCanceledException ex) catch (OperationCanceledException ex)
{ {
Logger.LogInfo("ValidateChildren cancelled for " + Name); Logger.Info("ValidateChildren cancelled for " + Name);
// If the outer cancelletion token in the cause for the cancellation, throw it // If the outer cancelletion token in the cause for the cancellation, throw it
if (cancellationToken.IsCancellationRequested && ex.CancellationToken == cancellationToken) if (cancellationToken.IsCancellationRequested && ex.CancellationToken == cancellationToken)
@ -734,7 +734,7 @@ namespace MediaBrowser.Controller.Entities
foreach (var item in changedArgs.ItemsRemoved) foreach (var item in changedArgs.ItemsRemoved)
{ {
Logger.LogInfo("** " + item.Name + " Removed from library."); Logger.Info("** " + item.Name + " Removed from library.");
} }
var childrenReplaced = false; var childrenReplaced = false;
@ -749,7 +749,7 @@ namespace MediaBrowser.Controller.Entities
foreach (var item in changedArgs.ItemsAdded) foreach (var item in changedArgs.ItemsAdded)
{ {
Logger.LogInfo("** " + item.Name + " Added to library."); Logger.Info("** " + item.Name + " Added to library.");
if (!childrenReplaced) if (!childrenReplaced)
{ {
@ -762,7 +762,7 @@ namespace MediaBrowser.Controller.Entities
await Task.WhenAll(saveTasks).ConfigureAwait(false); await Task.WhenAll(saveTasks).ConfigureAwait(false);
//and save children in repo... //and save children in repo...
Logger.LogInfo("*** Saving " + newChildren.Count + " children for " + Name); Logger.Info("*** Saving " + newChildren.Count + " children for " + Name);
await Kernel.Instance.ItemRepository.SaveChildren(Id, newChildren, CancellationToken.None).ConfigureAwait(false); await Kernel.Instance.ItemRepository.SaveChildren(Id, newChildren, CancellationToken.None).ConfigureAwait(false);
} }
@ -860,7 +860,7 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path); Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
return new List<BaseItem> { }; return new List<BaseItem> { };
} }
@ -1028,7 +1028,7 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path); Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
} }
//this should be functionally equivilent to what was here since it is IEnum and works on a thread-safe copy //this should be functionally equivilent to what was here since it is IEnum and works on a thread-safe copy
@ -1040,7 +1040,7 @@ namespace MediaBrowser.Controller.Entities
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path); Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
return false; return false;
} }
}); });

View file

@ -161,7 +161,7 @@ namespace MediaBrowser.Controller.Entities.Movies
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path); Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
return new List<Video> { }; return new List<Video> { };
} }
@ -179,7 +179,7 @@ namespace MediaBrowser.Controller.Entities.Movies
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.LogException("Error loading trailers for {0}", ex, Name); Logger.ErrorException("Error loading trailers for {0}", ex, Name);
return new List<Video> { }; return new List<Video> { };
} }

View file

@ -170,7 +170,7 @@ namespace MediaBrowser.Controller.Entities
get get
{ {
// Lazy load // Lazy load
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => XmlSerializer.GetXmlConfiguration<UserConfiguration>(ConfigurationFilePath)); LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => XmlSerializer.GetXmlConfiguration<UserConfiguration>(ConfigurationFilePath, Logger));
return _configuration; return _configuration;
} }
private set private set
@ -208,7 +208,7 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Task.</returns> /// <returns>Task.</returns>
public async Task ValidateMediaLibrary(IProgress<TaskProgress> progress, CancellationToken cancellationToken) public async Task ValidateMediaLibrary(IProgress<TaskProgress> progress, CancellationToken cancellationToken)
{ {
Logger.LogInfo("Validating media library for {0}", Name); Logger.Info("Validating media library for {0}", Name);
await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false); await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -224,7 +224,7 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Task.</returns> /// <returns>Task.</returns>
public async Task ValidateCollectionFolders(IProgress<TaskProgress> progress, CancellationToken cancellationToken) public async Task ValidateCollectionFolders(IProgress<TaskProgress> progress, CancellationToken cancellationToken)
{ {
Logger.LogInfo("Validating collection folders for {0}", Name); Logger.Info("Validating collection folders for {0}", Name);
await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false); await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();

View file

@ -70,9 +70,14 @@ namespace MediaBrowser.Controller.IO
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="DirectoryWatchers" /> class. /// Initializes a new instance of the <see cref="DirectoryWatchers" /> class.
/// </summary> /// </summary>
public DirectoryWatchers() public DirectoryWatchers(ILogger logger)
{ {
Logger = LogManager.GetLogger(GetType().Name); if (logger == null)
{
throw new ArgumentNullException("logger");
}
Logger = logger;
} }
/// <summary> /// <summary>

View file

@ -2,6 +2,7 @@
using MediaBrowser.Common.Logging; using MediaBrowser.Common.Logging;
using MediaBrowser.Common.Win32; using MediaBrowser.Common.Win32;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -14,6 +15,11 @@ namespace MediaBrowser.Controller.IO
/// </summary> /// </summary>
public static class FileData public static class FileData
{ {
/// <summary>
/// The logger
/// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("FileData");
/// <summary> /// <summary>
/// Gets all file system entries within a foler /// Gets all file system entries within a foler
/// </summary> /// </summary>
@ -87,7 +93,7 @@ namespace MediaBrowser.Controller.IO
if (string.IsNullOrWhiteSpace(newPath)) if (string.IsNullOrWhiteSpace(newPath))
{ {
//invalid shortcut - could be old or target could just be unavailable //invalid shortcut - could be old or target could just be unavailable
Logger.LogWarning("Encountered invalid shortuct: "+lpFindFileData.Path); Logger.Warn("Encountered invalid shortuct: "+lpFindFileData.Path);
continue; continue;
} }
var data = FileSystem.GetFileData(newPath); var data = FileSystem.GetFileData(newPath);

View file

@ -28,7 +28,7 @@ namespace MediaBrowser.Controller.IO
public FileSystemManager(Kernel kernel) public FileSystemManager(Kernel kernel)
: base(kernel) : base(kernel)
{ {
DirectoryWatchers = new DirectoryWatchers(); DirectoryWatchers = new DirectoryWatchers(Logger);
} }
/// <summary> /// <summary>

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using MediaBrowser.Common.Logging; using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Controller.Library namespace MediaBrowser.Controller.Library
{ {
@ -18,14 +19,22 @@ namespace MediaBrowser.Controller.Library
/// </summary> /// </summary>
readonly Stopwatch stopwatch; readonly Stopwatch stopwatch;
/// <summary>
/// The _logger
/// </summary>
private ILogger _logger;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Profiler" /> class. /// Initializes a new instance of the <see cref="Profiler" /> class.
/// </summary> /// </summary>
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
public Profiler(string name) /// <param name="logger">The logger.</param>
public Profiler(string name, ILogger logger)
{ {
this.name = name; this.name = name;
_logger = logger;
stopwatch = new Stopwatch(); stopwatch = new Stopwatch();
stopwatch.Start(); stopwatch.Start();
} }
@ -60,7 +69,7 @@ namespace MediaBrowser.Controller.Library
message = string.Format("{0} took {1} seconds.", message = string.Format("{0} took {1} seconds.",
name, ((float)stopwatch.ElapsedMilliseconds / 1000).ToString("#0.000")); name, ((float)stopwatch.ElapsedMilliseconds / 1000).ToString("#0.000"));
} }
Logger.LogInfo(message); _logger.Info(message);
} }
} }

View file

@ -1,5 +1,6 @@
using MediaBrowser.Common.Localization; using MediaBrowser.Common.Localization;
using MediaBrowser.Common.Logging; using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Logging;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Globalization; using System.Globalization;
@ -15,6 +16,10 @@ namespace MediaBrowser.Controller.Localization
/// </summary> /// </summary>
public class LocalizedStrings public class LocalizedStrings
{ {
/// <summary>
/// The logger
/// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("LocalizedStrings");
/// <summary> /// <summary>
/// The base prefix /// The base prefix
/// </summary> /// </summary>
@ -80,7 +85,7 @@ namespace MediaBrowser.Controller.Localization
var xs = new XmlSerializer(t); var xs = new XmlSerializer(t);
var strings = (LocalizedStringData)Activator.CreateInstance(t); var strings = (LocalizedStringData)Activator.CreateInstance(t);
strings.FileName = file; strings.FileName = file;
Logger.LogInfo("Using String Data from {0}", file); Logger.Info("Using String Data from {0}", file);
if (File.Exists(file)) if (File.Exists(file))
{ {
using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read)) using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read))
@ -121,17 +126,17 @@ namespace MediaBrowser.Controller.Localization
} }
catch (TargetException ex) catch (TargetException ex)
{ {
Logger.LogException("Error getting value for field: {0}", ex, field.Name); Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
continue; continue;
} }
catch (FieldAccessException ex) catch (FieldAccessException ex)
{ {
Logger.LogException("Error getting value for field: {0}", ex, field.Name); Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
continue; continue;
} }
catch (NotSupportedException ex) catch (NotSupportedException ex)
{ {
Logger.LogException("Error getting value for field: {0}", ex, field.Name); Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
continue; continue;
} }

View file

@ -2,6 +2,7 @@
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System; using System;
using System.Drawing; using System.Drawing;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -13,6 +14,10 @@ namespace MediaBrowser.Controller.Providers
/// </summary> /// </summary>
public abstract class BaseImageEnhancer : IDisposable public abstract class BaseImageEnhancer : IDisposable
{ {
/// <summary>
/// The logger
/// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("ImageEnhancer");
/// <summary> /// <summary>
/// Return true only if the given image for the given item will be enhanced by this enhancer. /// Return true only if the given image for the given item will be enhanced by this enhancer.
/// </summary> /// </summary>
@ -96,7 +101,7 @@ namespace MediaBrowser.Controller.Providers
var typeName = GetType().Name; var typeName = GetType().Name;
Logger.LogDebugInfo("Running {0} for {1}", typeName, item.Path ?? item.Name ?? "--Unknown--"); Logger.Debug("Running {0} for {1}", typeName, item.Path ?? item.Name ?? "--Unknown--");
try try
{ {
@ -104,7 +109,7 @@ namespace MediaBrowser.Controller.Providers
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogException("{0} failed enhancing {1}", ex, typeName, item.Name); Logger.ErrorException("{0} failed enhancing {1}", ex, typeName, item.Name);
throw; throw;
} }

View file

@ -1,6 +1,7 @@
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -16,6 +17,20 @@ namespace MediaBrowser.Controller.Providers
public class BaseItemXmlParser<T> public class BaseItemXmlParser<T>
where T : BaseItem, new() where T : BaseItem, new()
{ {
/// <summary>
/// The logger
/// </summary>
protected ILogger Logger { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="BaseItemXmlParser{T}" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
public BaseItemXmlParser(ILogger logger)
{
Logger = logger;
}
/// <summary> /// <summary>
/// Fetches metadata for an item from one xml file /// Fetches metadata for an item from one xml file
/// </summary> /// </summary>

View file

@ -72,7 +72,7 @@ namespace MediaBrowser.Controller.Providers
if (metadataFile.HasValue) if (metadataFile.HasValue)
{ {
var path = metadataFile.Value.Path; var path = metadataFile.Value.Path;
new BaseItemXmlParser<Folder>().Fetch((Folder)item, path, cancellationToken); new BaseItemXmlParser<Folder>(Logger).Fetch((Folder)item, path, cancellationToken);
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
return true; return true;
} }

View file

@ -75,11 +75,11 @@ namespace MediaBrowser.Controller.Providers.Movies
var boxset = item as BoxSet; var boxset = item as BoxSet;
if (boxset != null) if (boxset != null)
{ {
new BaseItemXmlParser<BoxSet>().Fetch(boxset, path, cancellationToken); new BaseItemXmlParser<BoxSet>(Logger).Fetch(boxset, path, cancellationToken);
} }
else else
{ {
new BaseItemXmlParser<Movie>().Fetch((Movie)item, path, cancellationToken); new BaseItemXmlParser<Movie>(Logger).Fetch((Movie)item, path, cancellationToken);
} }
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
return true; return true;

View file

@ -115,7 +115,7 @@ namespace MediaBrowser.Controller.Providers.TV
return false; return false;
} }
new EpisodeXmlParser().Fetch(item, metadataFile, cancellationToken); new EpisodeXmlParser(Logger).Fetch(item, metadataFile, cancellationToken);
return true; return true;
} }
} }

View file

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Logging;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
@ -9,6 +10,15 @@ namespace MediaBrowser.Controller.Providers.TV
/// </summary> /// </summary>
public class EpisodeXmlParser : BaseItemXmlParser<Episode> public class EpisodeXmlParser : BaseItemXmlParser<Episode>
{ {
/// <summary>
/// Initializes a new instance of the <see cref="EpisodeXmlParser" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
public EpisodeXmlParser(ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Fetches the data from XML node. /// Fetches the data from XML node.
/// </summary> /// </summary>

View file

@ -74,7 +74,7 @@ namespace MediaBrowser.Controller.Providers.TV
{ {
var path = metadataFile.Value.Path; var path = metadataFile.Value.Path;
new SeriesXmlParser().Fetch((Series)item, path, cancellationToken); new SeriesXmlParser(Logger).Fetch((Series)item, path, cancellationToken);
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
return true; return true;

View file

@ -1,7 +1,7 @@
using MediaBrowser.Common.Logging; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Resolvers.TV; using MediaBrowser.Controller.Resolvers.TV;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System; using System;
using System.Xml; using System.Xml;
@ -12,6 +12,15 @@ namespace MediaBrowser.Controller.Providers.TV
/// </summary> /// </summary>
public class SeriesXmlParser : BaseItemXmlParser<Series> public class SeriesXmlParser : BaseItemXmlParser<Series>
{ {
/// <summary>
/// Initializes a new instance of the <see cref="BaseItemXmlParser{T}" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
public SeriesXmlParser(ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Fetches the data from XML node. /// Fetches the data from XML node.
/// </summary> /// </summary>
@ -74,7 +83,7 @@ namespace MediaBrowser.Controller.Providers.TV
} }
else else
{ {
Logger.LogInfo("Unrecognized series status: " + status); Logger.Info("Unrecognized series status: " + status);
} }
} }

View file

@ -7,9 +7,18 @@ using System.Linq;
namespace MediaBrowser.Controller.Resolvers.TV namespace MediaBrowser.Controller.Resolvers.TV
{ {
/// <summary>
/// Class TVUtils
/// </summary>
public static class TVUtils public static class TVUtils
{ {
/// <summary>
/// The TVDB API key
/// </summary>
public static readonly string TVDBApiKey = "B89CE93890E9419B"; public static readonly string TVDBApiKey = "B89CE93890E9419B";
/// <summary>
/// The banner URL
/// </summary>
public static readonly string BannerUrl = "http://www.thetvdb.com/banners/"; public static readonly string BannerUrl = "http://www.thetvdb.com/banners/";
/// <summary> /// <summary>
@ -29,11 +38,6 @@ namespace MediaBrowser.Controller.Resolvers.TV
/// match movie titles like "2001 A Space..." /// match movie titles like "2001 A Space..."
/// Currently we limit the numbers here to 2 digits to try and avoid this /// Currently we limit the numbers here to 2 digits to try and avoid this
/// </summary> /// </summary>
/// <remarks>
/// The order here is important, if the order is changed some of the later
/// ones might incorrectly match things that higher ones would have caught.
/// The most restrictive expressions should appear first
/// </remarks>
private static readonly Regex[] EpisodeExpressions = new[] private static readonly Regex[] EpisodeExpressions = new[]
{ {
new Regex( new Regex(
@ -78,6 +82,11 @@ namespace MediaBrowser.Controller.Resolvers.TV
}; };
/// <summary>
/// Gets the season number from path.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>System.Nullable{System.Int32}.</returns>
public static int? GetSeasonNumberFromPath(string path) public static int? GetSeasonNumberFromPath(string path)
{ {
// Look for one of the season folder names // Look for one of the season folder names
@ -97,6 +106,8 @@ namespace MediaBrowser.Controller.Resolvers.TV
/// <summary> /// <summary>
/// Extracts the season number from the second half of the Season folder name (everything after "Season", or "Staffel") /// Extracts the season number from the second half of the Season folder name (everything after "Season", or "Staffel")
/// </summary> /// </summary>
/// <param name="path">The path.</param>
/// <returns>System.Nullable{System.Int32}.</returns>
private static int? GetSeasonNumberFromPathSubstring(string path) private static int? GetSeasonNumberFromPathSubstring(string path)
{ {
int numericStart = -1; int numericStart = -1;
@ -127,11 +138,22 @@ namespace MediaBrowser.Controller.Resolvers.TV
return int.Parse(path.Substring(numericStart, length)); return int.Parse(path.Substring(numericStart, length));
} }
/// <summary>
/// Determines whether [is season folder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
public static bool IsSeasonFolder(string path) public static bool IsSeasonFolder(string path)
{ {
return GetSeasonNumberFromPath(path) != null; return GetSeasonNumberFromPath(path) != null;
} }
/// <summary>
/// Determines whether [is series folder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <param name="fileSystemChildren">The file system children.</param>
/// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns>
public static bool IsSeriesFolder(string path, IEnumerable<WIN32_FIND_DATA> fileSystemChildren) public static bool IsSeriesFolder(string path, IEnumerable<WIN32_FIND_DATA> fileSystemChildren)
{ {
// A folder with more than 3 non-season folders in will not becounted as a series // A folder with more than 3 non-season folders in will not becounted as a series
@ -171,6 +193,12 @@ namespace MediaBrowser.Controller.Resolvers.TV
return false; return false;
} }
/// <summary>
/// Episodes the number from file.
/// </summary>
/// <param name="fullPath">The full path.</param>
/// <param name="isInSeason">if set to <c>true</c> [is in season].</param>
/// <returns>System.String.</returns>
public static string EpisodeNumberFromFile(string fullPath, bool isInSeason) public static string EpisodeNumberFromFile(string fullPath, bool isInSeason)
{ {
string fl = fullPath.ToLower(); string fl = fullPath.ToLower();
@ -194,6 +222,11 @@ namespace MediaBrowser.Controller.Resolvers.TV
return null; return null;
} }
/// <summary>
/// Seasons the number from episode file.
/// </summary>
/// <param name="fullPath">The full path.</param>
/// <returns>System.String.</returns>
public static string SeasonNumberFromEpisodeFile(string fullPath) public static string SeasonNumberFromEpisodeFile(string fullPath)
{ {
string fl = fullPath.ToLower(); string fl = fullPath.ToLower();
@ -211,6 +244,11 @@ namespace MediaBrowser.Controller.Resolvers.TV
return null; return null;
} }
/// <summary>
/// Gets the air days.
/// </summary>
/// <param name="day">The day.</param>
/// <returns>List{DayOfWeek}.</returns>
public static List<DayOfWeek> GetAirDays(string day) public static List<DayOfWeek> GetAirDays(string day)
{ {
if (!string.IsNullOrWhiteSpace(day)) if (!string.IsNullOrWhiteSpace(day))
@ -239,8 +277,6 @@ namespace MediaBrowser.Controller.Resolvers.TV
}; };
} }
Logger.LogWarning("Invalid value passed into GetAirDays: {0}", day);
return new List<DayOfWeek> return new List<DayOfWeek>
{ {
}; };

View file

@ -1,5 +1,4 @@
using MediaBrowser.Common.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Logging;
using System.Security; using System.Security;
namespace MediaBrowser.IsoMounter namespace MediaBrowser.IsoMounter
@ -12,7 +11,16 @@ namespace MediaBrowser.IsoMounter
/// <summary> /// <summary>
/// The logger /// The logger
/// </summary> /// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("MyPfmFileMountUi"); private readonly ILogger Logger;
/// <summary>
/// Initializes a new instance of the <see cref="MyPfmFileMountUi" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
public MyPfmFileMountUi(ILogger logger)
{
Logger = logger;
}
/// <summary> /// <summary>
/// Clears the password. /// Clears the password.

View file

@ -72,15 +72,21 @@ namespace MediaBrowser.IsoMounter
/// <value>The logger.</value> /// <value>The logger.</value>
private ILogger Logger { get; set; } private ILogger Logger { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="PismoIsoManager" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
public PismoIsoManager(ILogger logger) public PismoIsoManager(ILogger logger)
{ {
Logger = logger; Logger = logger;
_myPfmFileMountUi = new MyPfmFileMountUi(Logger);
} }
/// <summary> /// <summary>
/// The _my PFM file mount UI /// The _my PFM file mount UI
/// </summary> /// </summary>
private readonly MyPfmFileMountUi _myPfmFileMountUi = new MyPfmFileMountUi(); private readonly MyPfmFileMountUi _myPfmFileMountUi;
/// <summary> /// <summary>
/// Mounts the specified iso path. /// Mounts the specified iso path.
@ -151,6 +157,9 @@ namespace MediaBrowser.IsoMounter
return new PismoMount(mount, isoPath, this, Logger); return new PismoMount(mount, isoPath, this, Logger);
} }
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose() public void Dispose()
{ {
Dispose(true); Dispose(true);

View file

@ -2,6 +2,7 @@
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
@ -35,6 +36,16 @@ namespace MediaBrowser.Server.Sqlite
} }
} }
/// <summary>
/// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
protected SQLiteDisplayPreferencesRepository([Import("logger")] ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Opens the connection to the database /// Opens the connection to the database
/// </summary> /// </summary>

View file

@ -2,6 +2,7 @@ using MediaBrowser.Common.Serialization;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
@ -40,6 +41,16 @@ namespace MediaBrowser.Server.Sqlite
} }
} }
/// <summary>
/// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
protected SQLiteItemRepository([Import("logger")] ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Opens the connection to the database /// Opens the connection to the database
/// </summary> /// </summary>
@ -202,7 +213,7 @@ namespace MediaBrowser.Server.Sqlite
var itemType = _typeMapper.GetType(type); var itemType = _typeMapper.GetType(type);
if (itemType == null) if (itemType == null)
{ {
Logger.Error("Cannot find type {0}. Probably belongs to plug-in that is no longer loaded.",type); Logger.Error("Cannot find type {0}. Probably belongs to plug-in that is no longer loaded.", type);
continue; continue;
} }
var item = JsonSerializer.DeserializeFromStream(stream, itemType) as BaseItem; var item = JsonSerializer.DeserializeFromStream(stream, itemType) as BaseItem;

View file

@ -38,14 +38,33 @@ namespace MediaBrowser.Server.Sqlite
/// </summary> /// </summary>
private Timer FlushTimer; private Timer FlushTimer;
/// <summary>
/// Gets the logger.
/// </summary>
/// <value>The logger.</value>
protected ILogger Logger { get; private set; } protected ILogger Logger { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="SqliteRepository" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">logger</exception>
protected SqliteRepository(ILogger logger)
{
if (logger == null)
{
throw new ArgumentNullException("logger");
}
Logger = logger;
}
/// <summary> /// <summary>
/// Connects to DB. /// Connects to DB.
/// </summary> /// </summary>
/// <param name="dbPath">The db path.</param> /// <param name="dbPath">The db path.</param>
/// <returns>Task{System.Boolean}.</returns> /// <returns>Task{System.Boolean}.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException">dbPath</exception>
protected async Task ConnectToDB(string dbPath) protected async Task ConnectToDB(string dbPath)
{ {
if (string.IsNullOrEmpty(dbPath)) if (string.IsNullOrEmpty(dbPath))
@ -53,8 +72,6 @@ namespace MediaBrowser.Server.Sqlite
throw new ArgumentNullException("dbPath"); throw new ArgumentNullException("dbPath");
} }
Logger = LogManager.GetLogger(GetType().Name);
dbFileName = dbPath; dbFileName = dbPath;
var connectionstr = new SQLiteConnectionStringBuilder var connectionstr = new SQLiteConnectionStringBuilder
{ {
@ -78,7 +95,7 @@ namespace MediaBrowser.Server.Sqlite
/// </summary> /// </summary>
/// <param name="queries">The queries.</param> /// <param name="queries">The queries.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException">queries</exception>
protected void RunQueries(string[] queries) protected void RunQueries(string[] queries)
{ {
if (queries == null) if (queries == null)
@ -167,7 +184,7 @@ namespace MediaBrowser.Server.Sqlite
/// Queues the command. /// Queues the command.
/// </summary> /// </summary>
/// <param name="cmd">The CMD.</param> /// <param name="cmd">The CMD.</param>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException">cmd</exception>
protected void QueueCommand(SQLiteCommand cmd) protected void QueueCommand(SQLiteCommand cmd)
{ {
if (cmd == null) if (cmd == null)
@ -242,7 +259,7 @@ namespace MediaBrowser.Server.Sqlite
/// </summary> /// </summary>
/// <param name="cmd">The CMD.</param> /// <param name="cmd">The CMD.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException">cmd</exception>
public async Task ExecuteCommand(DbCommand cmd) public async Task ExecuteCommand(DbCommand cmd)
{ {
if (cmd == null) if (cmd == null)
@ -275,7 +292,7 @@ namespace MediaBrowser.Server.Sqlite
/// <param name="reader">The reader.</param> /// <param name="reader">The reader.</param>
/// <param name="ordinal">The ordinal.</param> /// <param name="ordinal">The ordinal.</param>
/// <returns>Stream.</returns> /// <returns>Stream.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException">reader</exception>
protected static Stream GetStream(IDataReader reader, int ordinal) protected static Stream GetStream(IDataReader reader, int ordinal)
{ {
if (reader == null) if (reader == null)

View file

@ -1,6 +1,7 @@
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
@ -34,6 +35,16 @@ namespace MediaBrowser.Server.Sqlite
} }
} }
/// <summary>
/// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
protected SQLiteUserDataRepository([Import("logger")] ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Opens the connection to the database /// Opens the connection to the database
/// </summary> /// </summary>
@ -108,7 +119,7 @@ namespace MediaBrowser.Server.Sqlite
/// </summary> /// </summary>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <returns>IEnumerable{UserItemData}.</returns> /// <returns>IEnumerable{UserItemData}.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException">item</exception>
public IEnumerable<UserItemData> RetrieveUserData(BaseItem item) public IEnumerable<UserItemData> RetrieveUserData(BaseItem item)
{ {
if (item == null) if (item == null)

View file

@ -9,6 +9,7 @@ using System.Data;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Server.Sqlite namespace MediaBrowser.Server.Sqlite
{ {
@ -35,6 +36,16 @@ namespace MediaBrowser.Server.Sqlite
} }
} }
/// <summary>
/// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
protected SQLiteUserRepository([Import("logger")] ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Opens the connection to the database /// Opens the connection to the database
/// </summary> /// </summary>

View file

@ -179,7 +179,7 @@ namespace MediaBrowser.ServerApplication
/// <returns>Window.</returns> /// <returns>Window.</returns>
protected override Window InstantiateMainWindow() protected override Window InstantiateMainWindow()
{ {
return new MainWindow(); return new MainWindow(LogManager.GetLogger("MainWindow"));
} }
} }
} }

View file

@ -20,7 +20,7 @@ namespace MediaBrowser.ServerApplication.Controls
/// <summary> /// <summary>
/// The logger /// The logger
/// </summary> /// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("MultiItemUpdateNotification"); private readonly ILogger Logger;
/// <summary> /// <summary>
/// Gets the children changed event args. /// Gets the children changed event args.
@ -34,8 +34,15 @@ namespace MediaBrowser.ServerApplication.Controls
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ItemUpdateNotification" /> class. /// Initializes a new instance of the <see cref="ItemUpdateNotification" /> class.
/// </summary> /// </summary>
public ItemUpdateNotification() public ItemUpdateNotification(ILogger logger)
{ {
if (logger == null)
{
throw new ArgumentNullException("logger");
}
Logger = logger;
InitializeComponent(); InitializeComponent();
Loaded += ItemUpdateNotification_Loaded; Loaded += ItemUpdateNotification_Loaded;

View file

@ -2,6 +2,7 @@
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -19,7 +20,7 @@ namespace MediaBrowser.ServerApplication.Controls
/// <summary> /// <summary>
/// The logger /// The logger
/// </summary> /// </summary>
private static readonly ILogger Logger = LogManager.GetLogger("MultiItemUpdateNotification"); private readonly ILogger Logger;
/// <summary> /// <summary>
/// Gets the children changed event args. /// Gets the children changed event args.
@ -33,8 +34,15 @@ namespace MediaBrowser.ServerApplication.Controls
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MultiItemUpdateNotification" /> class. /// Initializes a new instance of the <see cref="MultiItemUpdateNotification" /> class.
/// </summary> /// </summary>
public MultiItemUpdateNotification() public MultiItemUpdateNotification(ILogger logger)
{ {
if (logger == null)
{
throw new ArgumentNullException("logger");
}
Logger = logger;
InitializeComponent(); InitializeComponent();
Loaded += MultiItemUpdateNotification_Loaded; Loaded += MultiItemUpdateNotification_Loaded;

View file

@ -18,6 +18,7 @@ using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.ServerApplication namespace MediaBrowser.ServerApplication
{ {
@ -26,6 +27,8 @@ namespace MediaBrowser.ServerApplication
/// </summary> /// </summary>
public partial class LibraryExplorer : Window public partial class LibraryExplorer : Window
{ {
private ILogger _logger;
/// <summary> /// <summary>
/// The current user /// The current user
/// </summary> /// </summary>
@ -33,8 +36,10 @@ namespace MediaBrowser.ServerApplication
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LibraryExplorer" /> class. /// Initializes a new instance of the <see cref="LibraryExplorer" /> class.
/// </summary> /// </summary>
public LibraryExplorer() public LibraryExplorer(ILogger logger)
{ {
_logger = logger;
InitializeComponent(); InitializeComponent();
lblVersion.Content = "Version: " + Kernel.Instance.DisplayVersion; lblVersion.Content = "Version: " + Kernel.Instance.DisplayVersion;
foreach (var user in Kernel.Instance.Users) foreach (var user in Kernel.Instance.Users)
@ -311,7 +316,7 @@ namespace MediaBrowser.ServerApplication
{ {
using ( using (
new Profiler("Explorer full index expansion for " + new Profiler("Explorer full index expansion for " +
folder.Name)) folder.Name, _logger))
{ {
//re-build the current item's children as an index //re-build the current item's children as an index
prefs.IndexBy = ddlIndexBy.SelectedItem as string; prefs.IndexBy = ddlIndexBy.SelectedItem as string;
@ -352,7 +357,7 @@ namespace MediaBrowser.ServerApplication
{ {
using ( using (
new Profiler("Explorer sorting by " + ddlSortBy.SelectedItem + " for " + new Profiler("Explorer sorting by " + ddlSortBy.SelectedItem + " for " +
folder.Name)) folder.Name, _logger))
{ {
//re-sort //re-sort
prefs.SortBy = ddlSortBy.SelectedItem as string; prefs.SortBy = ddlSortBy.SelectedItem as string;

View file

@ -2,6 +2,7 @@
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using MediaBrowser.ServerApplication.Controls; using MediaBrowser.ServerApplication.Controls;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -37,11 +38,25 @@ namespace MediaBrowser.ServerApplication
/// <value>The new item timer.</value> /// <value>The new item timer.</value>
private Timer NewItemTimer { get; set; } private Timer NewItemTimer { get; set; }
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MainWindow" /> class. /// Initializes a new instance of the <see cref="MainWindow" /> class.
/// </summary> /// </summary>
public MainWindow() /// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">logger</exception>
public MainWindow(ILogger logger)
{ {
if (logger == null)
{
throw new ArgumentNullException("logger");
}
_logger = logger;
InitializeComponent(); InitializeComponent();
Loaded += MainWindowLoaded; Loaded += MainWindowLoaded;
@ -145,11 +160,19 @@ namespace MediaBrowser.ServerApplication
// Show the notification // Show the notification
if (newItems.Count == 1) if (newItems.Count == 1)
{ {
Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new ItemUpdateNotification { DataContext = newItems[0] }, PopupAnimation.Slide, 6000)); Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new ItemUpdateNotification(LogManager.GetLogger("ItemUpdateNotification"))
{
DataContext = newItems[0]
}, PopupAnimation.Slide, 6000));
} }
else if (newItems.Count > 1) else if (newItems.Count > 1)
{ {
Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new MultiItemUpdateNotification { DataContext = newItems }, PopupAnimation.Slide, 6000)); Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new MultiItemUpdateNotification(LogManager.GetLogger("ItemUpdateNotification"))
{
DataContext = newItems
}, PopupAnimation.Slide, 6000));
} }
} }
@ -246,7 +269,7 @@ namespace MediaBrowser.ServerApplication
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogException("Error in event handler", ex); _logger.ErrorException("Error in event handler", ex);
} }
} }
} }
@ -259,7 +282,7 @@ namespace MediaBrowser.ServerApplication
/// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
private void cmOpenExplorer_click(object sender, RoutedEventArgs e) private void cmOpenExplorer_click(object sender, RoutedEventArgs e)
{ {
(new LibraryExplorer()).Show(); (new LibraryExplorer(_logger)).Show();
} }
/// <summary> /// <summary>
@ -325,11 +348,5 @@ namespace MediaBrowser.ServerApplication
} }
#endregion #endregion
private void cmdApiDocs_Click_1(object sender, RoutedEventArgs e)
{
}
} }
} }

View file

@ -1,5 +1,6 @@
using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Kernel;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Model.Logging;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -20,6 +21,17 @@ namespace MediaBrowser.WebDashboard.Api
get { return "DashboardInfo"; } get { return "DashboardInfo"; }
} }
/// <summary>
/// Initializes a new instance of the <see cref="DashboardInfoWebSocketListener" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
public DashboardInfoWebSocketListener([Import("logger")] ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Gets the data to send. /// Gets the data to send.
/// </summary> /// </summary>