From 7cbe2410e4556da10f160920bdf1482ad98e848d Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 15 May 2015 22:20:09 +0200 Subject: [PATCH] Do not flood the log when installing a new version --- src/Umbraco.Core/ApplicationContext.cs | 18 +++++++++++------- src/Umbraco.Web/UmbracoModule.cs | 12 ++++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index f1bb929a94..382c3f29c4 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -165,6 +165,8 @@ namespace Umbraco.Core /// internal string OriginalRequestUrl { get; set; } + private bool _versionsDifferenceReported; + /// /// Checks if the version configured matches the assembly version /// @@ -174,17 +176,19 @@ namespace Umbraco.Core { try { - string configStatus = ConfigurationStatus; - string currentVersion = UmbracoVersion.Current.ToString(3); + var configStatus = ConfigurationStatus; + var currentVersion = UmbracoVersion.Current.ToString(3); + var ok = configStatus == currentVersion; - - if (currentVersion != configStatus) + if (ok == false && _versionsDifferenceReported == false) { - LogHelper.Info("CurrentVersion different from configStatus: '" + currentVersion + "','" + configStatus + "'"); + // remember it's been reported so we don't flood the log + // no thread-safety so there may be a few log entries, doesn't matter + _versionsDifferenceReported = true; + LogHelper.Info("CurrentVersion different from configStatus: '" + currentVersion + "','" + configStatus + "'"); } - - return (configStatus == currentVersion); + return ok; } catch { diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index f2d216f2fd..bc6037a683 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -409,15 +409,23 @@ namespace Umbraco.Web return false; } + private bool _notConfiguredReported; + // ensures Umbraco is configured // if not, redirect to install and return false // if yes, return true - private static bool EnsureIsConfigured(HttpContextBase httpContext, Uri uri) + private bool EnsureIsConfigured(HttpContextBase httpContext, Uri uri) { if (ApplicationContext.Current.IsConfigured) return true; - LogHelper.Warn("Umbraco is not configured"); + if (_notConfiguredReported) + { + // remember it's been reported so we don't flood the log + // no thread-safety so there may be a few log entries, doesn't matter + _notConfiguredReported = true; + LogHelper.Warn("Umbraco is not configured"); + } var installPath = UriUtility.ToAbsolute(SystemDirectories.Install); var installUrl = string.Format("{0}/?redir=true&url={1}", installPath, HttpUtility.UrlEncode(uri.ToString()));