aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/AppBase
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/AppBase')
-rw-r--r--Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs47
-rw-r--r--Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs22
2 files changed, 52 insertions, 17 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
index 52e421374..3e12bc0b6 100644
--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
@@ -1,5 +1,4 @@
-using System;
-using System.IO;
+using System.IO;
using MediaBrowser.Common.Configuration;
namespace Emby.Server.Implementations.AppBase
@@ -13,10 +12,16 @@ namespace Emby.Server.Implementations.AppBase
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
/// </summary>
- protected BaseApplicationPaths(string programDataPath, string appFolderPath)
+ protected BaseApplicationPaths(
+ string programDataPath,
+ string appFolderPath,
+ string logDirectoryPath = null,
+ string configurationDirectoryPath = null)
{
ProgramDataPath = programDataPath;
ProgramSystemPath = appFolderPath;
+ LogDirectoryPath = logDirectoryPath;
+ ConfigurationDirectoryPath = configurationDirectoryPath;
}
public string ProgramDataPath { get; private set; }
@@ -107,6 +112,11 @@ namespace Emby.Server.Implementations.AppBase
}
/// <summary>
+ /// The _log directory
+ /// </summary>
+ private string _logDirectoryPath;
+
+ /// <summary>
/// Gets the path to the log directory
/// </summary>
/// <value>The log directory path.</value>
@@ -114,11 +124,27 @@ namespace Emby.Server.Implementations.AppBase
{
get
{
- return Path.Combine(ProgramDataPath, "logs");
+ if (string.IsNullOrEmpty(_logDirectoryPath))
+ {
+ _logDirectoryPath = Path.Combine(ProgramDataPath, "logs");
+
+ Directory.CreateDirectory(_logDirectoryPath);
+ }
+
+ return _logDirectoryPath;
+ }
+ set
+ {
+ _logDirectoryPath = value;
}
}
/// <summary>
+ /// The _config directory
+ /// </summary>
+ private string _configurationDirectoryPath;
+
+ /// <summary>
/// Gets the path to the application configuration root directory
/// </summary>
/// <value>The configuration directory path.</value>
@@ -126,7 +152,18 @@ namespace Emby.Server.Implementations.AppBase
{
get
{
- return Path.Combine(ProgramDataPath, "config");
+ if (string.IsNullOrEmpty(_configurationDirectoryPath))
+ {
+ _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config");
+
+ Directory.CreateDirectory(_configurationDirectoryPath);
+ }
+
+ return _configurationDirectoryPath;
+ }
+ set
+ {
+ _configurationDirectoryPath = value;
}
}
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
index 385b4bd51..bc5168fe8 100644
--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
@@ -9,7 +9,7 @@ using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Logging;
+using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Serialization;
namespace Emby.Server.Implementations.AppBase
@@ -97,14 +97,14 @@ namespace Emby.Server.Implementations.AppBase
/// Initializes a new instance of the <see cref="BaseConfigurationManager" /> class.
/// </summary>
/// <param name="applicationPaths">The application paths.</param>
- /// <param name="logManager">The log manager.</param>
+ /// <param name="loggerFactory">The logger factory.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
- protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILogManager logManager, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
+ protected BaseConfigurationManager(IApplicationPaths applicationPaths, ILoggerFactory loggerFactory, IXmlSerializer xmlSerializer, IFileSystem fileSystem)
{
CommonApplicationPaths = applicationPaths;
XmlSerializer = xmlSerializer;
FileSystem = fileSystem;
- Logger = logManager.GetLogger(GetType().Name);
+ Logger = loggerFactory.CreateLogger(GetType().Name);
UpdateCachePath();
}
@@ -123,7 +123,7 @@ namespace Emby.Server.Implementations.AppBase
/// </summary>
public void SaveConfiguration()
{
- Logger.Info("Saving system configuration");
+ Logger.LogInformation("Saving system configuration");
var path = CommonApplicationPaths.SystemConfigurationFilePath;
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(path));
@@ -259,7 +259,7 @@ namespace Emby.Server.Implementations.AppBase
}
catch (Exception ex)
{
- Logger.ErrorException("Error loading configuration file: {0}", ex, path);
+ Logger.LogError(ex, "Error loading configuration file: {path}", path);
return Activator.CreateInstance(configurationType);
}
@@ -283,12 +283,11 @@ namespace Emby.Server.Implementations.AppBase
validatingStore.Validate(currentConfiguration, configuration);
}
- EventHelper.FireEventIfNotNull(NamedConfigurationUpdating, this, new ConfigurationUpdateEventArgs
+ NamedConfigurationUpdating?.Invoke( this, new ConfigurationUpdateEventArgs
{
Key = key,
NewConfiguration = configuration
-
- }, Logger);
+ });
_configurations.AddOrUpdate(key, configuration, (k, v) => configuration);
@@ -305,12 +304,11 @@ namespace Emby.Server.Implementations.AppBase
protected virtual void OnNamedConfigurationUpdated(string key, object configuration)
{
- EventHelper.FireEventIfNotNull(NamedConfigurationUpdated, this, new ConfigurationUpdateEventArgs
+ NamedConfigurationUpdated?.Invoke(this, new ConfigurationUpdateEventArgs
{
Key = key,
NewConfiguration = configuration
-
- }, Logger);
+ });
}
public Type GetConfigurationType(string key)