|
@@ -6,12 +6,12 @@ using System.Configuration;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Reflection;
|
|
-using MediaBrowser.Common.Configuration;
|
|
|
|
|
|
+using MediaBrowser.Model.Configuration;
|
|
using MediaBrowser.Common.Json;
|
|
using MediaBrowser.Common.Json;
|
|
-using MediaBrowser.Common.Logging;
|
|
|
|
using MediaBrowser.Common.Net;
|
|
using MediaBrowser.Common.Net;
|
|
using MediaBrowser.Common.Plugins;
|
|
using MediaBrowser.Common.Plugins;
|
|
-using MediaBrowser.Common.Progress;
|
|
|
|
|
|
+using MediaBrowser.Model.Progress;
|
|
|
|
+using MediaBrowser.Logging;
|
|
|
|
|
|
namespace MediaBrowser.Common.Kernel
|
|
namespace MediaBrowser.Common.Kernel
|
|
{
|
|
{
|
|
@@ -48,6 +48,22 @@ namespace MediaBrowser.Common.Kernel
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Gets the path to the log directory
|
|
|
|
+ /// </summary>
|
|
|
|
+ private string LogDirectoryPath
|
|
|
|
+ {
|
|
|
|
+ get
|
|
|
|
+ {
|
|
|
|
+ return Path.Combine(ProgramDataPath, "logs");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Gets or sets the path to the current log file
|
|
|
|
+ /// </summary>
|
|
|
|
+ private string LogFilePath { get; set; }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the current configuration
|
|
/// Gets the current configuration
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -73,12 +89,12 @@ namespace MediaBrowser.Common.Kernel
|
|
public BaseKernel()
|
|
public BaseKernel()
|
|
{
|
|
{
|
|
ProgramDataPath = GetProgramDataPath();
|
|
ProgramDataPath = GetProgramDataPath();
|
|
-
|
|
|
|
- Logger.LoggerInstance = new FileLogger(Path.Combine(ProgramDataPath, "Logs"));
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public virtual void Init(IProgress<TaskProgress> progress)
|
|
public virtual void Init(IProgress<TaskProgress> progress)
|
|
{
|
|
{
|
|
|
|
+ ReloadLogger();
|
|
|
|
+
|
|
ReloadConfiguration();
|
|
ReloadConfiguration();
|
|
|
|
|
|
ReloadHttpServer();
|
|
ReloadHttpServer();
|
|
@@ -86,6 +102,24 @@ namespace MediaBrowser.Common.Kernel
|
|
ReloadComposableParts();
|
|
ReloadComposableParts();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void ReloadLogger()
|
|
|
|
+ {
|
|
|
|
+ DisposeLogger();
|
|
|
|
+
|
|
|
|
+ if (!Directory.Exists(LogDirectoryPath))
|
|
|
|
+ {
|
|
|
|
+ Directory.CreateDirectory(LogDirectoryPath);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DateTime now = DateTime.Now;
|
|
|
|
+
|
|
|
|
+ LogFilePath = Path.Combine(LogDirectoryPath, now.ToString("dMyyyy") + "-" + now.Ticks + ".log");
|
|
|
|
+
|
|
|
|
+ FileStream fs = new FileStream(LogFilePath, FileMode.Append, FileAccess.Write, FileShare.Read);
|
|
|
|
+
|
|
|
|
+ Logger.LoggerInstance = new StreamLogger(fs);
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Uses MEF to locate plugins
|
|
/// Uses MEF to locate plugins
|
|
/// Subclasses can use this to locate types within plugins
|
|
/// Subclasses can use this to locate types within plugins
|
|
@@ -213,14 +247,6 @@ namespace MediaBrowser.Common.Kernel
|
|
HttpServer = new HttpServer("http://+:" + Configuration.HttpServerPortNumber + "/mediabrowser/");
|
|
HttpServer = new HttpServer("http://+:" + Configuration.HttpServerPortNumber + "/mediabrowser/");
|
|
}
|
|
}
|
|
|
|
|
|
- private void DisposeHttpServer()
|
|
|
|
- {
|
|
|
|
- if (HttpServer != null)
|
|
|
|
- {
|
|
|
|
- HttpServer.Dispose();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// This snippet will allow any plugin to reference another
|
|
/// This snippet will allow any plugin to reference another
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -244,6 +270,23 @@ namespace MediaBrowser.Common.Kernel
|
|
public void Dispose()
|
|
public void Dispose()
|
|
{
|
|
{
|
|
DisposeHttpServer();
|
|
DisposeHttpServer();
|
|
|
|
+ DisposeLogger();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void DisposeHttpServer()
|
|
|
|
+ {
|
|
|
|
+ if (HttpServer != null)
|
|
|
|
+ {
|
|
|
|
+ HttpServer.Dispose();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void DisposeLogger()
|
|
|
|
+ {
|
|
|
|
+ if (Logger.LoggerInstance != null)
|
|
|
|
+ {
|
|
|
|
+ Logger.LoggerInstance.Dispose();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|