diff --git a/src/Umbraco.Core/Components/BootLoader.cs b/src/Umbraco.Core/Components/BootLoader.cs index f11657d634..35ab6ff79a 100644 --- a/src/Umbraco.Core/Components/BootLoader.cs +++ b/src/Umbraco.Core/Components/BootLoader.cs @@ -347,7 +347,7 @@ namespace Umbraco.Core.Components { if (_booted == false) { - _proflog.Logger.Warn("Cannot terminate, has not booted."); + _proflog.Logger.Warn(() => "Cannot terminate, has not booted."); return; } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs index b7d869ee62..0becdc5a8c 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs @@ -37,7 +37,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 var keyName = c.Item3.ToLowerInvariant(); if (dups.Contains(keyName)) { - Logger.Warn("Duplicate constraint " + c.Item3); + Logger.Warn(() => $"Duplicate constraint {c.Item3}"); continue; } dups.Add(keyName); diff --git a/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs b/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs index 8f501c0aaa..0bbce78223 100644 --- a/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs +++ b/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs @@ -65,7 +65,7 @@ namespace Umbraco.Core.Persistence catch (DbException e) { // Don't swallow this error, the exception is super handy for knowing "why" its not available - Current.Logger.Warn(e, "Configured database is reporting as not being available."); + Current.Logger.Warn(e, () => "Configured database is reporting as not being available."); return false; } diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs index d33980ac46..051cdebd2b 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs @@ -563,7 +563,7 @@ AND umbracoNode.id <> @id", } else { - Logger.Warn>("Could not assign a data type for the property type " + propertyType.Alias + " since no data type was found with a property editor " + propertyType.PropertyEditorAlias); + Logger.Warn>(() => $"Could not assign a data type for the property type {propertyType.Alias} since no data type was found with a property editor {propertyType.PropertyEditorAlias}"); } } } diff --git a/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs index f235a95aa8..e8d16fcd62 100644 --- a/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs @@ -261,7 +261,7 @@ namespace Umbraco.Core.PropertyEditors var result = TryConvertValueToCrlType(editorValue.Value); if (result.Success == false) { - Current.Logger.Warn("The value " + editorValue.Value + " cannot be converted to the type " + ValueTypes.ToStorageType(ValueType)); + Current.Logger.Warn(() => $"The value {editorValue.Value} cannot be converted to the type {ValueTypes.ToStorageType(ValueType)}"); return null; } return result.Result; diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs index a3652b3330..4ea4361972 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs @@ -315,7 +315,7 @@ namespace Umbraco.Core.Runtime catch (Exception e) { // can connect to the database but cannot access the migration table... need to install - logger.Warn(e, "Could not check the upgrade state."); + logger.Warn(e, () => "Could not check the upgrade state."); logger.Debug("Could not check the upgrade state, need to install Umbraco."); _state.Level = RuntimeLevel.Install; return; diff --git a/src/Umbraco.Core/Scoping/ScopeProvider.cs b/src/Umbraco.Core/Scoping/ScopeProvider.cs index db45ca2754..beb1ee5374 100644 --- a/src/Umbraco.Core/Scoping/ScopeProvider.cs +++ b/src/Umbraco.Core/Scoping/ScopeProvider.cs @@ -117,7 +117,7 @@ namespace Umbraco.Core.Scoping } // hard to inject into a static method :( - Current.Logger.Warn("Missed " + typeof(T).Name + " Object " + objectKey.ToString("N").Substring(0, 8)); + Current.Logger.Warn(() => $"Missed {typeof(T).Name} Object {objectKey.ToString("N").Substring(0, 8)}"); #if DEBUG_SCOPES //Current.Logger.Debug("At:\r\n" + Head(Environment.StackTrace, 24)); #endif diff --git a/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs b/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs index 801d35d806..44587b616b 100644 --- a/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs +++ b/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs @@ -88,8 +88,7 @@ namespace Umbraco.Core.Services.Implement } catch (CultureNotFoundException) { - Current.Logger.Warn( - string.Format("The culture {0} found in the file {1} is not a valid culture", cultureVal, fileInfo.FullName)); + Current.Logger.Warn(() => $"The culture {cultureVal} found in the file {fileInfo.FullName} is not a valid culture"); //If the culture in the file is invalid, we'll just hope the file name is a valid culture below, otherwise // an exception will be thrown. } diff --git a/src/Umbraco.Core/Services/Implement/PackagingService.cs b/src/Umbraco.Core/Services/Implement/PackagingService.cs index 1e585053da..9c51b3081b 100644 --- a/src/Umbraco.Core/Services/Implement/PackagingService.cs +++ b/src/Umbraco.Core/Services/Implement/PackagingService.cs @@ -631,10 +631,7 @@ namespace Umbraco.Core.Services.Implement } else { - _logger.Warn( - string.Format( - "Packager: Error handling allowed templates. Template with alias '{0}' could not be found.", - alias)); + _logger.Warn(() => $"Packager: Error handling allowed templates. Template with alias '{alias}' could not be found."); } } @@ -650,10 +647,7 @@ namespace Umbraco.Core.Services.Implement } else { - _logger.Warn( - string.Format( - "Packager: Error handling default template. Default template with alias '{0}' could not be found.", - defaultTemplateElement.Value)); + _logger.Warn(() => $"Packager: Error handling default template. Default template with alias '{defaultTemplateElement.Value}' could not be found."); } } } @@ -724,11 +718,10 @@ namespace Umbraco.Core.Services.Implement // This means that the property will not be created. if (dataTypeDefinition == null) { - _logger.Warn( - string.Format("Packager: Error handling creation of PropertyType '{0}'. Could not find DataTypeDefintion with unique id '{1}' nor one referencing the DataType with a property editor alias (or legacy control id) '{2}'. Did the package creator forget to package up custom datatypes? This property will be converted to a label/readonly editor if one exists.", - property.Element("Name").Value, - dataTypeDefinitionId, - property.Element("Type").Value.Trim())); + _logger.Warn(() => $"Packager: Error handling creation of PropertyType '{property.Element("Name").Value}'. " + + $"Could not find DataTypeDefintion with unique id '{dataTypeDefinitionId}' nor one referencing the DataType with a " + + $"property editor alias (or legacy control id) '{property.Element("Type").Value.Trim()}'. " + + $"Did the package creator forget to package up custom datatypes? This property will be converted to a label/readonly editor if one exists."); //convert to a label! dataTypeDefinition = _dataTypeService.GetByEditorAlias(Constants.PropertyEditors.Aliases.NoEdit).FirstOrDefault(); @@ -772,7 +765,7 @@ namespace Umbraco.Core.Services.Implement var allowedChild = _importedContentTypes.ContainsKey(alias) ? _importedContentTypes[alias] : _contentTypeService.Get(alias); if (allowedChild == null) { - _logger.Warn($"Packager: Error handling DocumentType structure. DocumentType with alias '{alias}' could not be found and was not added to the structure for '{contentType.Alias}'."); + _logger.Warn(() => $"Packager: Error handling DocumentType structure. DocumentType with alias '{alias}' could not be found and was not added to the structure for '{contentType.Alias}'."); continue; } diff --git a/src/Umbraco.Core/Services/Implement/UserService.cs b/src/Umbraco.Core/Services/Implement/UserService.cs index 96cac1d814..30428e694c 100644 --- a/src/Umbraco.Core/Services/Implement/UserService.cs +++ b/src/Umbraco.Core/Services/Implement/UserService.cs @@ -333,7 +333,7 @@ namespace Umbraco.Core.Services.Implement // if we are upgrading and an exception occurs, log and swallow it if (_isUpgrading == false) throw; - Logger.Warn(ex, "An error occurred attempting to save a user instance during upgrade, normally this warning can be ignored"); + Logger.Warn(ex, () => "An error occurred attempting to save a user instance during upgrade, normally this warning can be ignored"); // we don't want the uow to rollback its scope! scope.Complete(); diff --git a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs index a1b89e58bc..35b5334801 100644 --- a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs +++ b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs @@ -142,7 +142,7 @@ namespace Umbraco.Core.Sync var idle =_syncIdle.WaitOne(5000); if (idle == false) { - Logger.Warn("The wait lock timed out, application is shutting down. The current instruction batch will be re-processed."); + Logger.Warn(() => "The wait lock timed out, application is shutting down. The current instruction batch will be re-processed."); } }, weight); @@ -178,7 +178,7 @@ namespace Umbraco.Core.Sync { // we haven't synced - in this case we aren't going to sync the whole thing, we will assume this is a new // server and it will need to rebuild it's own caches, eg Lucene or the xml cache file. - Logger.Warn("No last synced Id found, this generally means this is a new server/install." + Logger.Warn(() => "No last synced Id found, this generally means this is a new server/install." + " The server will build its caches and indexes, and then adjust its last synced Id to the latest found in" + " the database and maintain cache updates based on that Id."); diff --git a/src/Umbraco.Web/Editors/PasswordChanger.cs b/src/Umbraco.Web/Editors/PasswordChanger.cs index 08f010ecd4..7aa8c88848 100644 --- a/src/Umbraco.Web/Editors/PasswordChanger.cs +++ b/src/Umbraco.Web/Editors/PasswordChanger.cs @@ -188,7 +188,7 @@ namespace Umbraco.Web.Editors } catch (Exception ex) { - _logger.Warn(ex, "Could not reset member password"); + _logger.Warn(ex, () => "Could not reset member password"); return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not reset password, error: " + ex.Message + " (see log for full details)", new[] { "resetPassword" }) }); } } @@ -213,7 +213,7 @@ namespace Umbraco.Web.Editors } catch (Exception ex) { - _logger.Warn(ex, "Could not change member password"); + _logger.Warn(ex, () => "Could not change member password"); return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, error: " + ex.Message + " (see log for full details)", new[] { "value" }) }); } } @@ -242,7 +242,7 @@ namespace Umbraco.Web.Editors } catch (Exception ex) { - _logger.Warn(ex, "Could not change member password"); + _logger.Warn(ex, () => "Could not change member password"); return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, error: " + ex.Message + " (see log for full details)", new[] { "value" }) }); } } @@ -274,14 +274,14 @@ namespace Umbraco.Web.Editors } catch (Exception ex1) { - _logger.Warn(ex1, "Could not change member password"); + _logger.Warn(ex1, () => "Could not change member password"); return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, error: " + ex1.Message + " (see log for full details)", new[] { "value" }) }); } } catch (Exception ex2) { - _logger.Warn(ex2, "Could not retrieve member password"); + _logger.Warn(ex2, () => "Could not retrieve member password"); return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, error: " + ex2.Message + " (see log for full details)", new[] { "value" }) }); } } diff --git a/src/Umbraco.Web/Macros/MacroRenderer.cs b/src/Umbraco.Web/Macros/MacroRenderer.cs index 8320e881b1..cf8dcb76d5 100644 --- a/src/Umbraco.Web/Macros/MacroRenderer.cs +++ b/src/Umbraco.Web/Macros/MacroRenderer.cs @@ -304,7 +304,7 @@ namespace Umbraco.Web.Macros { Exceptions.Add(e); - _plogger.Logger.Warn(e, "Failed " + msgIn); + _plogger.Logger.Warn(e, () => $"Failed {msgIn}"); var macroErrorEventArgs = new MacroErrorEventArgs { diff --git a/src/Umbraco.Web/Macros/UserControlMacroEngine.cs b/src/Umbraco.Web/Macros/UserControlMacroEngine.cs index 67122f9f56..98246084f9 100644 --- a/src/Umbraco.Web/Macros/UserControlMacroEngine.cs +++ b/src/Umbraco.Web/Macros/UserControlMacroEngine.cs @@ -78,12 +78,12 @@ namespace Umbraco.Web.Macros } catch (Exception e) { - Current.Logger.Warn(e, $"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\"."); + Current.Logger.Warn(e, () => $"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\"."); } } else { - Current.Logger.Warn($"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\"."); + Current.Logger.Warn(() => $"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\"."); } } } diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs index 98e8346441..2e873b5178 100644 --- a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs @@ -78,7 +78,7 @@ namespace Umbraco.Web.PropertyEditors catch (Exception ex) { // for some reason the value is invalid so continue as if there was no value there - _logger.Warn(ex, "Could not parse current db value to a JObject."); + _logger.Warn(ex, () => "Could not parse current db value to a JObject."); } if (string.IsNullOrWhiteSpace(currentPath) == false) currentPath = _mediaFileSystem.GetRelativePath(currentPath);