Removing last of log entries that do string concat or interpolation & updates to use MessageTemplate format instead

This commit is contained in:
Warren Buckley
2018-11-06 10:25:35 +00:00
parent d5294568ce
commit 1ef487b7da
14 changed files with 23 additions and 23 deletions

View File

@@ -423,7 +423,7 @@ namespace Umbraco.Core.Migrations.Install
var tableExist = TableExists(tableName);
if (overwrite && tableExist)
{
_logger.Info<DatabaseSchemaCreator>($"Table '{tableName}' already exists, but will be recreated");
_logger.Info<DatabaseSchemaCreator>("Table '{TableName}' already exists, but will be recreated", tableName);
DropTable(tableName);
tableExist = false;
@@ -481,18 +481,18 @@ namespace Umbraco.Core.Migrations.Install
if (overwrite)
{
_logger.Info<Database>($"Table '{tableName}' was recreated");
_logger.Info<Database>("Table '{TableName}' was recreated", tableName);
}
else
{
_logger.Info<Database>($"New table '{tableName}' was created");
_logger.Info<Database>("New table '{TableName}' was created", tableName);
}
}
}
else
{
// The table exists and was not recreated/overwritten.
_logger.Info<Database>($"Table '{tableName}' already exists - no changes were made");
_logger.Info<Database>("Table '{TableName}' already exists - no changes were made", tableName);
}
}

View File

@@ -108,7 +108,7 @@ namespace Umbraco.Tests.Services
total.AddRange(ServiceContext.ContentService.GetPagedDescendants(content.Id, 0, int.MaxValue, out var _));
}
TestProfiler.Disable();
Current.Logger.Info<ContentServicePerformanceTest>("Returned " + total.Count + " items");
Current.Logger.Info<ContentServicePerformanceTest>("Returned {Total} items", total.Count);
}
}

View File

@@ -50,7 +50,7 @@ namespace Umbraco.Web.ContentApps
// dying is not user-friendly, so let's write to log instead, and wish people read logs...
//throw new InvalidOperationException($"Duplicate content app aliases found: {string.Join(",", dups)}");
_logger.Warn<ContentAppDefinitionCollection>($"Duplicate content app aliases found: {string.Join(",", dups)}");
_logger.Warn<ContentAppDefinitionCollection>("Duplicate content app aliases found: {DuplicateAliases}", string.Join(",", dups));
}
return apps;

View File

@@ -94,7 +94,7 @@ namespace Umbraco.Web.Editors
if (parts.Length != 2)
{
Logger.Warn<BackOfficeController>("VerifyUser endpoint reached with invalid token: " + invite);
Logger.Warn<BackOfficeController>("VerifyUser endpoint reached with invalid token: {Invite}", invite);
return RedirectToAction("Default");
}
@@ -103,7 +103,7 @@ namespace Umbraco.Web.Editors
var decoded = token.FromUrlBase64();
if (decoded.IsNullOrWhiteSpace())
{
Logger.Warn<BackOfficeController>("VerifyUser endpoint reached with invalid token: " + invite);
Logger.Warn<BackOfficeController>("VerifyUser endpoint reached with invalid token: {Invite}", invite);
return RedirectToAction("Default");
}
@@ -111,14 +111,14 @@ namespace Umbraco.Web.Editors
int intId;
if (int.TryParse(id, out intId) == false)
{
Logger.Warn<BackOfficeController>("VerifyUser endpoint reached with invalid token: " + invite);
Logger.Warn<BackOfficeController>("VerifyUser endpoint reached with invalid token: {Invite}", invite);
return RedirectToAction("Default");
}
var identityUser = await UserManager.FindByIdAsync(intId);
if (identityUser == null)
{
Logger.Warn<BackOfficeController>("VerifyUser endpoint reached with non existing user: " + id);
Logger.Warn<BackOfficeController>("VerifyUser endpoint reached with non existing user: {UserId}", id);
return RedirectToAction("Default");
}
@@ -126,7 +126,7 @@ namespace Umbraco.Web.Editors
if (result.Succeeded == false)
{
Logger.Warn<BackOfficeController>("Could not verify email, Error: " + string.Join(",", result.Errors) + ", Token: " + invite);
Logger.Warn<BackOfficeController>("Could not verify email, Error: {Errors}, Token: {Invite}", string.Join(",", result.Errors), invite);
return new RedirectResult(Url.Action("Default") + "#/login/false?invite=3");
}
@@ -382,7 +382,7 @@ namespace Umbraco.Web.Editors
var authType = OwinContext.Authentication.GetExternalAuthenticationTypes().FirstOrDefault(x => x.AuthenticationType == loginInfo.Login.LoginProvider);
if (authType == null)
{
Logger.Warn<BackOfficeController>("Could not find external authentication provider registered: " + loginInfo.Login.LoginProvider);
Logger.Warn<BackOfficeController>("Could not find external authentication provider registered: {LoginProvider}", loginInfo.Login.LoginProvider);
}
else
{
@@ -405,7 +405,7 @@ namespace Umbraco.Web.Editors
shouldSignIn = autoLinkOptions.OnExternalLogin(user, loginInfo);
if (shouldSignIn == false)
{
Logger.Warn<BackOfficeController>("The AutoLinkOptions of the external authentication provider '" + loginInfo.Login.LoginProvider + "' have refused the login based on the OnExternalLogin method. Affected user id: '" + user.Id + "'");
Logger.Warn<BackOfficeController>("The AutoLinkOptions of the external authentication provider '{LoginProvider}' have refused the login based on the OnExternalLogin method. Affected user id: '{UserId}'", loginInfo.Login.LoginProvider, user.Id);
}
}

View File

@@ -1439,7 +1439,7 @@ namespace Umbraco.Web.Editors
if (template == null && contentSave.TemplateAlias.IsNullOrWhiteSpace() == false)
{
//ModelState.AddModelError("Template", "No template exists with the specified alias: " + contentItem.TemplateAlias);
Logger.Warn<ContentController>("No template exists with the specified alias: " + contentSave.TemplateAlias);
Logger.Warn<ContentController>("No template exists with the specified alias: {TemplateAlias}", contentSave.TemplateAlias);
}
else
{

View File

@@ -59,7 +59,7 @@ namespace Umbraco.Web.Editors
// get the property editor
if (propertyDto.PropertyEditor == null)
{
Logger.Warn<ContentController>("No property editor found for property " + propertyDto.Alias);
Logger.Warn<ContentController>("No property editor found for property {PropertyAlias}", propertyDto.Alias);
continue;
}

View File

@@ -149,7 +149,7 @@ namespace Umbraco.Web.Editors
var msg = ValidateLuceneIndexer(indexerName, out LuceneIndexer indexer);
if (msg.IsSuccessStatusCode)
{
_logger.Info<ExamineManagementController>($"Rebuilding index '{indexerName}'");
_logger.Info<ExamineManagementController>("Rebuilding index '{IndexerName}'", indexerName);
//remove it in case there's a handler there alraedy
indexer.IndexOperationComplete -= Indexer_IndexOperationComplete;

View File

@@ -71,7 +71,7 @@ namespace Umbraco.Web.HealthCheck
}
catch (Exception ex)
{
_logger.Error<HealthCheckController>(ex, "Exception in health check: {HealthCheckName}" + check.Name);
_logger.Error<HealthCheckController>(ex, "Exception in health check: {HealthCheckName}", check.Name);
throw;
}
}

View File

@@ -43,7 +43,7 @@ namespace Umbraco.Web.Migrations
var count = scope.Database.Execute(sql);
_logger.Info<ClearMediaXmlCacheForDeletedItemsAfterUpgrade>("Cleared " + count + " items from the media xml cache that were trashed and not meant to be there");
_logger.Info<ClearMediaXmlCacheForDeletedItemsAfterUpgrade>("Cleared {Total} items from the media xml cache that were trashed and not meant to be there", count);
}
}
}

View File

@@ -38,7 +38,7 @@ namespace Umbraco.Web.Migrations
{
//backup
var targetPath = Path.Combine(tempCssFolder, relativePath.EnsureEndsWith(".bak"));
logger.Info<OverwriteStylesheetFilesFromTempFiles>($"CSS file is being backed up from {cssFilePath}, to {targetPath} before being migrated to new format");
logger.Info<OverwriteStylesheetFilesFromTempFiles>("CSS file is being backed up from {CssFilePath}, to {TargetPath} before being migrated to new format", cssFilePath, targetPath);
File.Copy(cssFilePath, targetPath, true);
}

View File

@@ -60,7 +60,7 @@ namespace Umbraco.Web.Mvc
var result = ViewEngines.Engines.FindView(ControllerContext, template, null);
if (result.View != null) return true;
Logger.Warn<RenderMvcController>("No physical template file was found for template " + template);
Logger.Warn<RenderMvcController>("No physical template file was found for template {Template}", template);
return false;
}

View File

@@ -59,7 +59,7 @@ namespace Umbraco.Web.Scheduling
{
var taskResult = await GetTaskByHttpAync(t.Url, token);
if (t.Log)
_logger.Info<ScheduledTasks>(string.Format("{0} has been called with response: {1}", t.Alias, taskResult));
_logger.Info<ScheduledTasks>("{TaskAlias} has been called with response: {TaskResult}", t.Alias, taskResult);
}
}
}

View File

@@ -136,7 +136,7 @@ namespace Umbraco.Web.Trees
// TODO: in the future we could return a validation statement so we can have some UI to notify the user they don't have access
if (HasPathAccess(id, queryStrings) == false)
{
Logger.Warn<ContentTreeControllerBase>("User " + Security.CurrentUser.Username + " does not have access to node with id " + id);
Logger.Warn<ContentTreeControllerBase>("User {Username} does not have access to node with id {Id}", Security.CurrentUser.Username, id);
return nodes;
}

View File

@@ -38,7 +38,7 @@ namespace umbraco.cms.businesslogic.packager {
{
#if DEBUG
_saveHitCount++;
Current.Logger.Info<InstalledPackage>("The InstalledPackage class save method has been hit " + _saveHitCount + " times.");
Current.Logger.Info<InstalledPackage>("The InstalledPackage class save method has been hit {Total} times.", _saveHitCount);
#endif
this.FireBeforeSave(EventArgs.Empty);
data.Save(this.Data, IOHelper.MapPath(Settings.InstalledPackagesSettings));