// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Collections.Generic;
using Microsoft.Extensions.Options;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Services;
namespace Umbraco.Core.HealthChecks.Checks.LiveEnvironment
{
///
/// Health check for the configuration of debug-flag.
///
[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")]
public class CompilationDebugCheck : AbstractSettingsCheck
{
private readonly IOptionsMonitor _hostingSettings;
///
/// Initializes a new instance of the class.
///
public CompilationDebugCheck(ILocalizedTextService textService, IOptionsMonitor hostingSettings)
: base(textService) =>
_hostingSettings = hostingSettings;
///
public override string ItemPath => Constants.Configuration.ConfigHostingDebug;
///
public override string ReadMoreLink => Constants.HealthChecks.DocumentationLinks.LiveEnvironment.CompilationDebugCheck;
///
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
///
public override IEnumerable Values => new List
{
new AcceptableConfiguration
{
IsRecommended = true,
Value = bool.FalseString.ToLower()
}
};
///
public override string CurrentValue => _hostingSettings.CurrentValue.Debug.ToString();
///
public override string CheckSuccessMessage => LocalizedTextService.Localize("healthcheck/compilationDebugCheckSuccessMessage");
///
public override string CheckErrorMessage => LocalizedTextService.Localize("healthcheck/compilationDebugCheckErrorMessage");
}
}