Update more logging messages to use templates as opposed to string formats that were using the LoggerExtensions <T>

This commit is contained in:
Warren
2018-08-16 12:00:12 +01:00
parent d632b46f9a
commit 47c8651609
24 changed files with 88 additions and 60 deletions

View File

@@ -1240,11 +1240,11 @@ namespace Umbraco.Core.Services.Implement
d.PublishCulture(); // fixme variants?
result = SaveAndPublish(d, userId: d.WriterId);
if (result.Success == false)
Logger.Error<ContentService>($"Failed to publish document id={d.Id}, reason={result.Result}.");
Logger.Error<ContentService>("Failed to publish document id={DocumentId}, reason={Reason}.", null, d.Id, result.Result);
}
catch (Exception e)
{
Logger.Error<ContentService>($"Failed to publish document id={d.Id}, an exception was thrown.", e);
Logger.Error<ContentService>("Failed to publish document id={DocumentId}, an exception was thrown.", e, d.Id);
throw;
}
yield return result;
@@ -1256,11 +1256,11 @@ namespace Umbraco.Core.Services.Implement
d.ExpireDate = null;
var result = Unpublish(d, userId: d.WriterId);
if (result.Success == false)
Logger.Error<ContentService>($"Failed to unpublish document id={d.Id}, reason={result.Result}.");
Logger.Error<ContentService>("Failed to unpublish document id={DocumentId}, reason={Reason}.", null, d.Id, result.Result);
}
catch (Exception e)
{
Logger.Error<ContentService>($"Failed to unpublish document id={d.Id}, an exception was thrown.", e);
Logger.Error<ContentService>("Failed to unpublish document id={DocumentId}, an exception was thrown.", e, d.Id);
throw;
}
}
@@ -1439,7 +1439,7 @@ namespace Umbraco.Core.Services.Implement
// fixme not going to work, do it differently
_mediaFileSystem.DeleteFiles(args.MediaFilesToDelete, // remove flagged files
(file, e) => Logger.Error<ContentService>("An error occurred while deleting file attached to nodes: " + file, e));
(file, e) => Logger.Error<ContentService>("An error occurred while deleting file attached to nodes: {File}", e, file));
}
}

View File

@@ -204,7 +204,7 @@ namespace Umbraco.Core.Services.Implement
}
catch (Exception ex)
{
_logger.Error<LocalizedTextServiceFileSources>("Could not load file into XML " + supplementaryFile.File.FullName, ex);
_logger.Error<LocalizedTextServiceFileSources>("Could not load file into XML {File}", ex, supplementaryFile.File.FullName);
continue;
}

View File

@@ -892,7 +892,7 @@ namespace Umbraco.Core.Services.Implement
scope.Events.Dispatch(Deleted, this, args);
_mediaFileSystem.DeleteFiles(args.MediaFilesToDelete, // remove flagged files
(file, e) => Logger.Error<MediaService>("An error occurred while deleting file attached to nodes: " + file, e));
(file, e) => Logger.Error<MediaService>("An error occurred while deleting file attached to nodes: {File}", e, file));
}
}

View File

@@ -930,7 +930,7 @@ namespace Umbraco.Core.Services.Implement
// fixme - this is MOOT because the event will not trigger immediately
// it's been refactored already (think it's the dispatcher that deals with it?)
_mediaFileSystem.DeleteFiles(args.MediaFilesToDelete, // remove flagged files
(file, e) => Logger.Error<MemberService>("An error occurred while deleting file attached to nodes: " + file, e));
(file, e) => Logger.Error<MemberService>("An error occurred while deleting file attached to nodes: {File}", e, file));
}
#endregion

View File

@@ -491,7 +491,7 @@ namespace Umbraco.Core.Services.Implement
var tryCreateFolder = _contentTypeService.CreateContainer(-1, rootFolder);
if (tryCreateFolder == false)
{
_logger.Error<PackagingService>("Could not create folder: " + rootFolder, tryCreateFolder.Exception);
_logger.Error<PackagingService>("Could not create folder: {FolderName}", tryCreateFolder.Exception, rootFolder);
throw tryCreateFolder.Exception;
}
var rootFolderId = tryCreateFolder.Result.Entity.Id;
@@ -525,7 +525,7 @@ namespace Umbraco.Core.Services.Implement
var tryCreateFolder = _contentTypeService.CreateContainer(current.Id, folderName);
if (tryCreateFolder == false)
{
_logger.Error<PackagingService>("Could not create folder: " + folderName, tryCreateFolder.Exception);
_logger.Error<PackagingService>("Could not create folder: {FolderName}", tryCreateFolder.Exception, folderName);
throw tryCreateFolder.Exception;
}
return _contentTypeService.GetContainer(tryCreateFolder.Result.Entity.Id);
@@ -949,7 +949,7 @@ namespace Umbraco.Core.Services.Implement
var tryCreateFolder = _dataTypeService.CreateContainer(-1, rootFolder);
if (tryCreateFolder == false)
{
_logger.Error<PackagingService>("Could not create folder: " + rootFolder, tryCreateFolder.Exception);
_logger.Error<PackagingService>("Could not create folder: {FolderName}", tryCreateFolder.Exception, rootFolder);
throw tryCreateFolder.Exception;
}
current = _dataTypeService.GetContainer(tryCreateFolder.Result.Entity.Id);
@@ -982,7 +982,7 @@ namespace Umbraco.Core.Services.Implement
var tryCreateFolder = _dataTypeService.CreateContainer(current.Id, folderName);
if (tryCreateFolder == false)
{
_logger.Error<PackagingService>("Could not create folder: " + folderName, tryCreateFolder.Exception);
_logger.Error<PackagingService>("Could not create folder: {FolderName}", tryCreateFolder.Exception, folderName);
throw tryCreateFolder.Exception;
}
return _dataTypeService.GetContainer(tryCreateFolder.Result.Entity.Id);
@@ -1529,7 +1529,10 @@ namespace Umbraco.Core.Services.Implement
else if (string.IsNullOrEmpty((string)elementCopy.Element("Master")) == false &&
templateElements.Any(x => (string)x.Element("Alias") == (string)elementCopy.Element("Master")) == false)
{
_logger.Info<PackagingService>(string.Format("Template '{0}' has an invalid Master '{1}', so the reference has been ignored.", (string)elementCopy.Element("Alias"), (string)elementCopy.Element("Master")));
_logger.Info<PackagingService>(
"Template '{TemplateAlias}' has an invalid Master '{TemplateMaster}', so the reference has been ignored.",
(string) elementCopy.Element("Alias"),
(string) elementCopy.Element("Master"));
}
graph.AddItem(TopoGraph.CreateNode((string) elementCopy.Element("Alias"), elementCopy, dependencies));