Merge pull request #2751 from lkoruba/hackathon-use-logger-warn-with-func
(V8 Hackathon) use logger warn with func<string>
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
var keyName = c.Item3.ToLowerInvariant();
|
||||
if (dups.Contains(keyName))
|
||||
{
|
||||
Logger.Warn<RefactorXmlColumns>("Duplicate constraint " + c.Item3);
|
||||
Logger.Warn<RefactorXmlColumns>(() => $"Duplicate constraint {c.Item3}");
|
||||
continue;
|
||||
}
|
||||
dups.Add(keyName);
|
||||
|
||||
@@ -563,7 +563,7 @@ AND umbracoNode.id <> @id",
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warn<ContentTypeRepositoryBase<TEntity>>("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<ContentTypeRepositoryBase<TEntity>>(() => $"Could not assign a data type for the property type {propertyType.Alias} since no data type was found with a property editor {propertyType.PropertyEditorAlias}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
var result = TryConvertValueToCrlType(editorValue.Value);
|
||||
if (result.Success == false)
|
||||
{
|
||||
Current.Logger.Warn<DataValueEditor>("The value " + editorValue.Value + " cannot be converted to the type " + ValueTypes.ToStorageType(ValueType));
|
||||
Current.Logger.Warn<DataValueEditor>(() => $"The value {editorValue.Value} cannot be converted to the type {ValueTypes.ToStorageType(ValueType)}");
|
||||
return null;
|
||||
}
|
||||
return result.Result;
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Umbraco.Core.Scoping
|
||||
}
|
||||
|
||||
// hard to inject into a static method :(
|
||||
Current.Logger.Warn<ScopeProvider>("Missed " + typeof(T).Name + " Object " + objectKey.ToString("N").Substring(0, 8));
|
||||
Current.Logger.Warn<ScopeProvider>(() => $"Missed {typeof(T).Name} Object {objectKey.ToString("N").Substring(0, 8)}");
|
||||
#if DEBUG_SCOPES
|
||||
//Current.Logger.Debug<ScopeProvider>("At:\r\n" + Head(Environment.StackTrace, 24));
|
||||
#endif
|
||||
|
||||
@@ -88,8 +88,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
catch (CultureNotFoundException)
|
||||
{
|
||||
Current.Logger.Warn<LocalizedTextServiceFileSources>(
|
||||
string.Format("The culture {0} found in the file {1} is not a valid culture", cultureVal, fileInfo.FullName));
|
||||
Current.Logger.Warn<LocalizedTextServiceFileSources>(() => $"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.
|
||||
}
|
||||
|
||||
@@ -631,10 +631,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Warn<PackagingService>(
|
||||
string.Format(
|
||||
"Packager: Error handling allowed templates. Template with alias '{0}' could not be found.",
|
||||
alias));
|
||||
_logger.Warn<PackagingService>(() => $"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<PackagingService>(
|
||||
string.Format(
|
||||
"Packager: Error handling default template. Default template with alias '{0}' could not be found.",
|
||||
defaultTemplateElement.Value));
|
||||
_logger.Warn<PackagingService>(() => $"Packager: Error handling default template. Default template with alias '{defaultTemplateElement.Value}' could not be found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -724,11 +718,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
// This means that the property will not be created.
|
||||
if (dataTypeDefinition == null)
|
||||
{
|
||||
_logger.Warn<PackagingService>(
|
||||
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<PackagingService>(() => $"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 +762,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
var allowedChild = _importedContentTypes.ContainsKey(alias) ? _importedContentTypes[alias] : _contentTypeService.Get(alias);
|
||||
if (allowedChild == null)
|
||||
{
|
||||
_logger.Warn<PackagingService>($"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<PackagingService>(() => $"Packager: Error handling DocumentType structure. DocumentType with alias '{alias}' could not be found and was not added to the structure for '{contentType.Alias}'.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ namespace Umbraco.Web
|
||||
|
||||
if (_databaseFactory.CanConnect == false)
|
||||
{
|
||||
Logger.Warn<BatchedDatabaseServerMessenger>(
|
||||
"Cannot connect to the database, distributed calls will not be enabled for this server.");
|
||||
Logger.Warn<BatchedDatabaseServerMessenger>("Cannot connect to the database, distributed calls will not be enabled for this server.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Umbraco.Web.Editors
|
||||
if (resetResult.Succeeded == false)
|
||||
{
|
||||
var errors = string.Join(". ", resetResult.Errors);
|
||||
_logger.Warn<PasswordChanger>($"Could not reset user password {errors}");
|
||||
_logger.Warn<PasswordChanger>(() => $"Could not reset user password {errors}");
|
||||
return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not reset password, errors: " + errors, new[] { "resetPassword" }) });
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Umbraco.Web.Editors
|
||||
if (changeResult.Succeeded == false)
|
||||
{
|
||||
var errors = string.Join(". ", changeResult.Errors);
|
||||
_logger.Warn<PasswordChanger>($"Could not change user password {errors}");
|
||||
_logger.Warn<PasswordChanger>(() => $"Could not change user password {errors}");
|
||||
return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, errors: " + errors, new[] { "oldPassword" }) });
|
||||
}
|
||||
return Attempt.Succeed(new PasswordChangedModel());
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Web.HealthCheck
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warn<HealthCheckResults>($" Checks for '{checkName}' completed with errors.");
|
||||
Logger.Warn<HealthCheckResults>(() => $" Checks for '{checkName}' completed with errors.");
|
||||
}
|
||||
|
||||
foreach (var checkResult in checkResults)
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace Umbraco.Web.Macros
|
||||
{
|
||||
Exceptions.Add(e);
|
||||
|
||||
_plogger.Logger.Warn<MacroRenderer>(e, "Failed " + msgIn);
|
||||
_plogger.Logger.Warn<MacroRenderer>(e, () => $"Failed {msgIn}");
|
||||
|
||||
var macroErrorEventArgs = new MacroErrorEventArgs
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Umbraco.Web.Macros
|
||||
var controlProperty = type.GetProperty(modelProperty.Key);
|
||||
if (controlProperty == null)
|
||||
{
|
||||
Current.Logger.Warn<UserControlMacroEngine>($"Control property \"{modelProperty.Key}\" doesn't exist or isn't accessible, skip.");
|
||||
Current.Logger.Warn<UserControlMacroEngine>(() => $"Control property \"{modelProperty.Key}\" doesn't exist or isn't accessible, skip.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -78,12 +78,12 @@ namespace Umbraco.Web.Macros
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Current.Logger.Warn<UserControlMacroEngine>(e, $"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\".");
|
||||
Current.Logger.Warn<UserControlMacroEngine>(e, () => $"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\".");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Current.Logger.Warn<UserControlMacroEngine>($"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\".");
|
||||
Current.Logger.Warn<UserControlMacroEngine>(() => $"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
if (configuration.TryGetValue(field.Key, out var value))
|
||||
field.Value = value;
|
||||
else // weird - just leave the field without a value - but warn
|
||||
Current.Logger.Warn<DataTypeConfigurationFieldDisplayResolver>($"Could not find a value for configuration field \"{field.Key}\".");
|
||||
Current.Logger.Warn<DataTypeConfigurationFieldDisplayResolver>(() => $"Could not find a value for configuration field \"{field.Key}\".");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
//we'll just map this to a text box
|
||||
paramEditor = Current.ParameterEditors[Constants.PropertyEditors.Aliases.TextBox];
|
||||
Current.Logger.Warn<MacroMapperProfile>("Could not resolve a parameter editor with alias " + property.EditorAlias + ", a textbox will be rendered in it's place");
|
||||
Current.Logger.Warn<MacroMapperProfile>(() => $"Could not resolve a parameter editor with alias {property.EditorAlias}, a textbox will be rendered in it's place");
|
||||
}
|
||||
|
||||
parameter.View = paramEditor.GetValueEditor().View;
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Warn<RelatedLinksValueConverter>($"Related Links value converter skipped a link as the node has been unpublished/deleted (Internal Link NodeId: {relatedLink.Link}, Link Caption: \"{relatedLink.Caption}\")");
|
||||
_logger.Warn<RelatedLinksValueConverter>(() => $"Related Links value converter skipped a link as the node has been unpublished/deleted (Internal Link NodeId: {relatedLink.Link}, Link Caption: \"{relatedLink.Caption}\")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
throw new Exception("Missing cmsContentNu edited content for node " + dto.Id + ", consider rebuilding.");
|
||||
Current.Logger.Warn<DatabaseDataSource>("Missing cmsContentNu edited content for node " + dto.Id + ", consider rebuilding.");
|
||||
Current.Logger.Warn<DatabaseDataSource>(() => $"Missing cmsContentNu edited content for node {dto.Id}, consider rebuilding.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -211,7 +211,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
throw new Exception("Missing cmsContentNu published content for node " + dto.Id + ", consider rebuilding.");
|
||||
Current.Logger.Warn<DatabaseDataSource>("Missing cmsContentNu published content for node " + dto.Id + ", consider rebuilding.");
|
||||
Current.Logger.Warn<DatabaseDataSource>(() => $"Missing cmsContentNu published content for node {dto.Id}, consider rebuilding.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
else
|
||||
{
|
||||
// this is a property that does not correspond to anything, ignore and log
|
||||
Current.Logger.Warn<PublishedMediaCache>("Dropping property \"" + i.Key + "\" because it does not belong to the content type.");
|
||||
Current.Logger.Warn<PublishedMediaCache>(() => "Dropping property \"" + i.Key + "\" because it does not belong to the content type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace Umbraco.Web.Security
|
||||
if (member == null)
|
||||
{
|
||||
//this should not happen
|
||||
Current.Logger.Warn<MembershipHelper>("The member validated but then no member was returned with the username " + username);
|
||||
Current.Logger.Warn<MembershipHelper>(() => $"The member validated but then no member was returned with the username {username}");
|
||||
return false;
|
||||
}
|
||||
//Log them in
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace Umbraco.Web.Security.Providers
|
||||
if (MemberService.Exists(username))
|
||||
{
|
||||
status = MembershipCreateStatus.DuplicateUserName;
|
||||
Current.Logger.Warn<UmbracoMembershipProvider<T, TEntity>>("Cannot create member as username already exists: " + username);
|
||||
Current.Logger.Warn<UmbracoMembershipProvider<T, TEntity>>(() => $"Cannot create member as username already exists: {username}");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -157,8 +157,7 @@ namespace Umbraco.Web.Security.Providers
|
||||
if (MemberService.GetByEmail(email) != null && RequiresUniqueEmail)
|
||||
{
|
||||
status = MembershipCreateStatus.DuplicateEmail;
|
||||
Current.Logger.Warn<UmbracoMembershipProvider<T, TEntity>>(
|
||||
"Cannot create member as a member with the same email address exists: " + email);
|
||||
Current.Logger.Warn<UmbracoMembershipProvider<T, TEntity>>(() => $"Cannot create member as a member with the same email address exists: {email}");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Umbraco.Web.Services
|
||||
var clrType = Type.GetType(type);
|
||||
if (clrType == null)
|
||||
{
|
||||
_logger.Warn<ApplicationTreeService>("The tree definition: " + addElement.ToString() + " could not be resolved to a .Net object type");
|
||||
_logger.Warn<ApplicationTreeService>(() => $"The tree definition: {addElement} could not be resolved to a .Net object type");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user