2016-06-13 17:42:05 +02:00
|
|
|
|
using System.Collections.Generic;
|
2020-09-21 13:04:57 +02:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2020-10-21 10:29:25 +01:00
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
using Umbraco.Core.Configuration.Models;
|
|
|
|
|
|
using Umbraco.Core.HealthCheck;
|
|
|
|
|
|
using Umbraco.Core.HealthCheck.Checks;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
using Umbraco.Core.Services;
|
|
|
|
|
|
|
2020-10-21 10:29:25 +01:00
|
|
|
|
namespace Umbraco.Core.Configuration.HealthChecks
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
|
|
|
|
|
[HealthCheck("61214FF3-FC57-4B31-B5CF-1D095C977D6D", "Debug Compilation Mode",
|
|
|
|
|
|
Description = "Leaving debug compilation mode enabled can severely slow down a website and take up more memory on the server.",
|
|
|
|
|
|
Group = "Live Environment")]
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public class CompilationDebugCheck : AbstractSettingsCheck
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
2020-10-21 10:29:25 +01:00
|
|
|
|
private readonly IOptionsMonitor<HostingSettings> _hostingSettings;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public CompilationDebugCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory, IOptionsMonitor<HostingSettings> hostingSettings)
|
|
|
|
|
|
: base(textService, loggerFactory)
|
|
|
|
|
|
{
|
|
|
|
|
|
_hostingSettings = hostingSettings;
|
|
|
|
|
|
}
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public override string ItemPath => Constants.Configuration.ConfigHostingDebug;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration>
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
2020-10-21 10:29:25 +01:00
|
|
|
|
new AcceptableConfiguration
|
|
|
|
|
|
{
|
|
|
|
|
|
IsRecommended = true,
|
|
|
|
|
|
Value = bool.FalseString.ToLower()
|
|
|
|
|
|
}
|
2016-09-01 19:06:08 +02:00
|
|
|
|
};
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public override string CurrentValue => _hostingSettings.CurrentValue.Debug.ToString();
|
|
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
public override string CheckSuccessMessage => TextService.Localize("healthcheck/compilationDebugCheckSuccessMessage");
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
public override string CheckErrorMessage => TextService.Localize("healthcheck/compilationDebugCheckErrorMessage");
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
public override string RectifySuccessMessage => TextService.Localize("healthcheck/compilationDebugCheckRectifySuccessMessage");
|
2016-06-13 17:42:05 +02:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|