Change GetAbsoluteLoggingPath to extension method

This commit is contained in:
Ronald Barendse
2022-12-12 09:11:44 +01:00
parent 311c11074f
commit a49151f552
2 changed files with 42 additions and 16 deletions

View File

@@ -2,13 +2,11 @@
// See LICENSE for more details.
using System.ComponentModel;
using Microsoft.Extensions.Hosting;
using Umbraco.Cms.Core.Extensions;
namespace Umbraco.Cms.Core.Configuration.Models;
/// <summary>
/// Typed configuration options for logging settings.
/// Typed configuration options for logging settings.
/// </summary>
[UmbracoOptions(Constants.Configuration.ConfigLogging)]
public class LoggingSettings
@@ -17,25 +15,20 @@ public class LoggingSettings
internal const string StaticDirectory = Constants.SystemDirectories.LogFiles;
/// <summary>
/// Gets or sets a value for the maximum age of a log file.
/// Gets or sets a value for the maximum age of a log file.
/// </summary>
/// <value>
/// The maximum log age.
/// </value>
[DefaultValue(StaticMaxLogAge)]
public TimeSpan MaxLogAge { get; set; } = TimeSpan.Parse(StaticMaxLogAge);
/// <summary>
/// Gets or sets the folder to use for log files
/// Gets or sets the folder to use for log files.
/// </summary>
/// <value>
/// The directory.
/// </value>
[DefaultValue(StaticDirectory)]
public string Directory { get; set; } = StaticDirectory;
public string GetAbsoluteLoggingPath(IHostEnvironment hostEnvironment)
{
var dir = Directory;
if (dir.StartsWith("~/"))
{
return hostEnvironment.MapPathContentRoot(dir);
}
return dir;
}
}