aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common.Implementations')
-rw-r--r--MediaBrowser.Common.Implementations/BaseApplicationHost.cs19
-rw-r--r--MediaBrowser.Common.Implementations/BaseApplicationPaths.cs9
-rw-r--r--MediaBrowser.Common.Implementations/Logging/NlogManager.cs41
3 files changed, 56 insertions, 13 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index f333eb22c..c0ac6a4b3 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -1,6 +1,5 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Events;
-using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Common.Implementations.NetworkManagement;
using MediaBrowser.Common.Implementations.ScheduledTasks;
using MediaBrowser.Common.Implementations.Security;
@@ -71,7 +70,7 @@ namespace MediaBrowser.Common.Implementations
/// Gets the application paths.
/// </summary>
/// <value>The application paths.</value>
- protected TApplicationPathsType ApplicationPaths = new TApplicationPathsType();
+ protected TApplicationPathsType ApplicationPaths { get; private set; }
/// <summary>
/// The container
@@ -153,11 +152,12 @@ namespace MediaBrowser.Common.Implementations
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationHost{TApplicationPathsType}"/> class.
/// </summary>
- protected BaseApplicationHost()
+ protected BaseApplicationHost(TApplicationPathsType applicationPaths, ILogManager logManager)
{
FailedAssemblies = new List<string>();
- LogManager = new NlogManager(ApplicationPaths.LogDirectoryPath, LogFilePrefixName);
+ ApplicationPaths = applicationPaths;
+ LogManager = logManager;
ConfigurationManager = GetConfigurationManager();
}
@@ -172,7 +172,10 @@ namespace MediaBrowser.Common.Implementations
Logger = LogManager.GetLogger("App");
- LogManager.ReloadLogger(ConfigurationManager.CommonConfiguration.EnableDebugLevelLogging ? LogSeverity.Debug : LogSeverity.Info);
+ LogManager.LogSeverity = ConfigurationManager.CommonConfiguration.EnableDebugLevelLogging
+ ? LogSeverity.Debug
+ : LogSeverity.Info;
+
OnLoggerLoaded();
DiscoverTypes();
@@ -212,12 +215,6 @@ namespace MediaBrowser.Common.Implementations
protected abstract IEnumerable<Assembly> GetComposablePartAssemblies();
/// <summary>
- /// Gets the name of the log file prefix.
- /// </summary>
- /// <value>The name of the log file prefix.</value>
- protected abstract string LogFilePrefixName { get; }
-
- /// <summary>
/// Gets the configuration manager.
/// </summary>
/// <returns>IConfigurationManager.</returns>
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs
index f6667f236..c177bd1ed 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs
@@ -27,6 +27,15 @@ namespace MediaBrowser.Common.Implementations
}
/// <summary>
+ /// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
+ /// </summary>
+ /// <param name="programDataPath">The program data path.</param>
+ protected BaseApplicationPaths(string programDataPath)
+ {
+ _programDataPath = programDataPath;
+ }
+
+ /// <summary>
/// The _program data path
/// </summary>
private string _programDataPath;
diff --git a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
index cd3dc5c16..109e85d80 100644
--- a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
+++ b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
@@ -1,10 +1,10 @@
-using System.Linq;
-using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.Logging;
using NLog;
using NLog.Config;
using NLog.Targets;
using System;
using System.IO;
+using System.Linq;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Implementations.Logging
@@ -45,6 +45,41 @@ namespace MediaBrowser.Common.Implementations.Logging
LogFilePrefix = logFileNamePrefix;
}
+ private LogSeverity _severity = LogSeverity.Debug;
+ public LogSeverity LogSeverity
+ {
+ get
+ {
+ return _severity;
+ }
+ set
+ {
+ var changed = _severity != value;
+
+ _severity = value;
+
+ if (changed)
+ {
+ UpdateLogLevel(value);
+ }
+ }
+ }
+
+ private void UpdateLogLevel(LogSeverity newLevel)
+ {
+ var level = GetLogLevel(newLevel);
+
+ var rules = LogManager.Configuration.LoggingRules;
+
+ foreach (var rule in rules)
+ {
+ if (!rule.IsLoggingEnabledForLevel(level))
+ {
+ rule.EnableLoggingForLevel(level);
+ }
+ }
+ }
+
/// <summary>
/// Adds the file target.
/// </summary>
@@ -154,6 +189,8 @@ namespace MediaBrowser.Common.Implementations.Logging
AddFileTarget(LogFilePath, level);
+ LogSeverity = level;
+
if (LoggerLoaded != null)
{
Task.Run(() =>