From 7660e10098a071de0288a410b1f4ae6b774d69fb Mon Sep 17 00:00:00 2001 From: Dawid Koruba Date: Fri, 29 Jun 2018 14:25:17 +0200 Subject: [PATCH] Change calls to logger.Info method to use Func parameter --- src/Umbraco.Core/Components/BootLoader.cs | 2 +- .../ClientDependencyConfiguration.cs | 4 +- src/Umbraco.Core/IO/PhysicalFileSystem.cs | 2 +- src/Umbraco.Core/Logging/LogProfiler.cs | 2 +- .../Migrations/Install/DatabaseBuilder.cs | 10 ++--- .../Migrations/Install/DatabaseDataCreator.cs | 4 +- .../Install/DatabaseSchemaCreator.cs | 12 +++--- src/Umbraco.Core/Migrations/MigrationPlan.cs | 13 +++--- .../Services/Implement/ContentService.cs | 20 ++++----- .../Editors/AuthenticationController.cs | 4 +- .../HealthCheck/HealthCheckResults.cs | 4 +- .../Macros/UserControlMacroEngine.cs | 2 +- .../Scheduling/BackgroundTaskRunner.cs | 8 ++-- src/Umbraco.Web/Search/ExamineComponent.cs | 4 +- .../Providers/UmbracoMembershipProvider.cs | 42 ++++++------------- .../ExamineManagementApiController.cs | 4 +- 16 files changed, 61 insertions(+), 76 deletions(-) diff --git a/src/Umbraco.Core/Components/BootLoader.cs b/src/Umbraco.Core/Components/BootLoader.cs index f11657d634..ee38864933 100644 --- a/src/Umbraco.Core/Components/BootLoader.cs +++ b/src/Umbraco.Core/Components/BootLoader.cs @@ -111,7 +111,7 @@ namespace Umbraco.Core.Components catch (Exception e) { // in case of an error, force-dump everything to log - _logger.Info(GetComponentsReport(requirements)); + _logger.Info(() => GetComponentsReport(requirements)); _logger.Error("Failed to sort components.", e); throw; } diff --git a/src/Umbraco.Core/Configuration/ClientDependencyConfiguration.cs b/src/Umbraco.Core/Configuration/ClientDependencyConfiguration.cs index 8693f2e6e8..0dcef568ce 100644 --- a/src/Umbraco.Core/Configuration/ClientDependencyConfiguration.cs +++ b/src/Umbraco.Core/Configuration/ClientDependencyConfiguration.cs @@ -79,7 +79,7 @@ namespace Umbraco.Core.Configuration versionAttribute.SetValue(newVersion); clientDependencyConfigXml.Save(_fileName, SaveOptions.DisableFormatting); - _logger.Info(string.Format("Updated version number from {0} to {1}", oldVersion, newVersion)); + _logger.Info(() => $"Updated version number from {oldVersion} to {newVersion}"); return true; } } @@ -113,7 +113,7 @@ namespace Umbraco.Core.Configuration versionAttribute.SetValue(newVersion); clientDependencyConfigXml.Save(_fileName, SaveOptions.DisableFormatting); - _logger.Info(string.Format("Updated version number from {0} to {1}", oldVersion, newVersion)); + _logger.Info(() => $"Updated version number from {oldVersion} to {newVersion}"); return true; } } diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Core/IO/PhysicalFileSystem.cs index 9a2c6eb1de..da0db83de3 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Core/IO/PhysicalFileSystem.cs @@ -226,7 +226,7 @@ namespace Umbraco.Core.IO } catch (FileNotFoundException ex) { - Current.Logger.Info(string.Format("DeleteFile failed with FileNotFoundException: {0}", ex.InnerException)); + Current.Logger.Info(() => $"DeleteFile failed with FileNotFoundException: {ex.InnerException}"); } } diff --git a/src/Umbraco.Core/Logging/LogProfiler.cs b/src/Umbraco.Core/Logging/LogProfiler.cs index 8610c2059c..6fbb1b2e26 100644 --- a/src/Umbraco.Core/Logging/LogProfiler.cs +++ b/src/Umbraco.Core/Logging/LogProfiler.cs @@ -25,7 +25,7 @@ namespace Umbraco.Core.Logging public IDisposable Step(string name) { _logger.Debug(() => $"Begin: {name}."); - return new LightDisposableTimer(duration => _logger.Info($"End {name}. ({duration}ms)")); + return new LightDisposableTimer(duration => _logger.Info(() => $"End {name}. ({duration}ms)")); } /// diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs index 2ed5fda7af..9e2af56b7b 100644 --- a/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs +++ b/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs @@ -309,7 +309,7 @@ namespace Umbraco.Core.Migrations.Install { var source = connectionStrings.Attribute("configSource").Value; var configFile = IOHelper.MapPath($"{SystemDirectories.Root}/{source}"); - logger.Info($"Storing ConnectionString in {configFile}"); + logger.Info(() => $"Storing ConnectionString in {configFile}"); if (File.Exists(configFile)) { xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace); @@ -335,7 +335,7 @@ namespace Umbraco.Core.Migrations.Install } xml.Save(fileName, SaveOptions.DisableFormatting); - logger.Info("Configured a new ConnectionString using the '" + providerName + "' provider."); + logger.Info(() => $"Configured a new ConnectionString using the '{providerName}' provider."); } internal bool IsConnectionStringConfigured(ConnectionStringSettings databaseSettings) @@ -500,7 +500,7 @@ namespace Umbraco.Core.Migrations.Install message = message + "

Installation completed!

"; //now that everything is done, we need to determine the version of SQL server that is executing - _logger.Info("Database configuration status: " + message); + _logger.Info(() => $"Database configuration status: {message}"); return new Result { Message = message, Success = true, Percentage = "100" }; } @@ -589,7 +589,7 @@ namespace Umbraco.Core.Migrations.Install //now that everything is done, we need to determine the version of SQL server that is executing - _logger.Info("Database configuration status: " + message); + _logger.Info(() => $"Database configuration status: {message}"); return new Result { Message = message, Success = true, Percentage = "100" }; } @@ -662,7 +662,7 @@ namespace Umbraco.Core.Migrations.Install if (_databaseSchemaValidationResult != null) { - _logger.Info("The database schema validation produced the following summary: \n" + _databaseSchemaValidationResult.GetSummary()); + _logger.Info(() => $"The database schema validation produced the following summary: {Environment.NewLine}{_databaseSchemaValidationResult.GetSummary()}"); } return new Result diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs index ac14dca7c6..8063ba9f46 100644 --- a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs +++ b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs @@ -29,7 +29,7 @@ namespace Umbraco.Core.Migrations.Install /// Name of the table to create base data for public void InitializeBaseData(string tableName) { - _logger.Info($"Creating data in table {tableName}"); + _logger.Info(() => $"Creating data in table {tableName}"); if (tableName.Equals(Constants.DatabaseSchema.Tables.Node)) CreateNodeData(); @@ -76,7 +76,7 @@ namespace Umbraco.Core.Migrations.Install if (tableName.Equals(Constants.DatabaseSchema.Tables.KeyValue)) CreateKeyValueData(); - _logger.Info($"Done creating table {tableName} data."); + _logger.Info(() => $"Done creating table {tableName} data."); } private void CreateNodeData() diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs b/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs index a5c6c18f39..94988e2687 100644 --- a/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs +++ b/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs @@ -98,7 +98,7 @@ namespace Umbraco.Core.Migrations.Install var tableNameAttribute = table.FirstAttribute(); var tableName = tableNameAttribute == null ? table.Name : tableNameAttribute.Value; - _logger.Info("Uninstall" + tableName); + _logger.Info(() => $"Uninstall {tableName}"); try { @@ -388,13 +388,13 @@ namespace Umbraco.Core.Migrations.Install { //Execute the Create Table sql var created = _database.Execute(new Sql(createSql)); - _logger.Info($"Create Table '{tableName}' ({created}):\n {createSql}"); + _logger.Info(() => $"Create Table '{tableName}' ({created}):\n {createSql}"); //If any statements exists for the primary key execute them here if (string.IsNullOrEmpty(createPrimaryKeySql) == false) { var createdPk = _database.Execute(new Sql(createPrimaryKeySql)); - _logger.Info($"Create Primary Key ({createdPk}):\n {createPrimaryKeySql}"); + _logger.Info(() => $"Create Primary Key ({createdPk}):\n {createPrimaryKeySql}"); } //Turn on identity insert if db provider is not mysql @@ -420,21 +420,21 @@ namespace Umbraco.Core.Migrations.Install foreach (var sql in indexSql) { var createdIndex = _database.Execute(new Sql(sql)); - _logger.Info($"Create Index ({createdIndex}):\n {sql}"); + _logger.Info(() => $"Create Index ({createdIndex}):\n {sql}"); } //Loop through foreignkey statements and execute sql foreach (var sql in foreignSql) { var createdFk = _database.Execute(new Sql(sql)); - _logger.Info($"Create Foreign Key ({createdFk}):\n {sql}"); + _logger.Info(() => $"Create Foreign Key ({createdFk}):\n {sql}"); } transaction.Complete(); } } - _logger.Info($"Created table '{tableName}'"); + _logger.Info(() => $"Created table '{tableName}'"); } public void DropTable(string tableName) diff --git a/src/Umbraco.Core/Migrations/MigrationPlan.cs b/src/Umbraco.Core/Migrations/MigrationPlan.cs index 4ca900aecd..7bf51d74f1 100644 --- a/src/Umbraco.Core/Migrations/MigrationPlan.cs +++ b/src/Umbraco.Core/Migrations/MigrationPlan.cs @@ -211,11 +211,14 @@ namespace Umbraco.Core.Migrations if (_migrationBuilder == null || _logger == null) throw new InvalidOperationException("Cannot execute a non-executing plan."); - _logger.Info($"Starting \"{Name}\"..."); + _logger.Info(() => $"Starting \"{Name}\"..."); var origState = fromState ?? string.Empty; - var info = "At " + (string.IsNullOrWhiteSpace(origState) ? "origin" : ("\"" + origState + "\"")) + "."; - info = info.Replace("{", "{{").Replace("}", "}}"); // stupid log4net - _logger.Info(info); + + _logger.Info(() => + { + var info = "At " + (string.IsNullOrWhiteSpace(origState) ? "origin" : ("\"" + origState + "\"")) + "."; + return info.Replace("{", "{{").Replace("}", "}}"); // stupid log4net + }); if (!_transitions.TryGetValue(origState, out var transition)) throw new Exception($"Unknown state \"{origState}\"."); @@ -230,7 +233,7 @@ namespace Umbraco.Core.Migrations var nextState = transition.TargetState; origState = nextState; - _logger.Info($"At \"{origState}\"."); + _logger.Info(() => $"At \"{origState}\"."); if (!_transitions.TryGetValue(origState, out transition)) throw new Exception($"Unknown state \"{origState}\"."); diff --git a/src/Umbraco.Core/Services/Implement/ContentService.cs b/src/Umbraco.Core/Services/Implement/ContentService.cs index b1ff14899c..0c0015019a 100644 --- a/src/Umbraco.Core/Services/Implement/ContentService.cs +++ b/src/Umbraco.Core/Services/Implement/ContentService.cs @@ -2094,7 +2094,7 @@ namespace Umbraco.Core.Services.Implement // raise Publishing event if (scope.Events.DispatchCancelable(Publishing, this, new PublishEventArgs(content, evtMsgs))) { - Logger.Info($"Document \"'{content.Name}\" (id={content.Id}) cannot be published: publishing was cancelled."); + Logger.Info(() => $"Document \"'{content.Name}\" (id={content.Id}) cannot be published: publishing was cancelled."); return new PublishResult(PublishResultType.FailedCancelledByEvent, evtMsgs, content); } @@ -2102,7 +2102,7 @@ namespace Umbraco.Core.Services.Implement // either because it is 'publishing' or because it already has a published version if (((Content) content).PublishedState != PublishedState.Publishing && content.PublishedVersionId == 0) { - Logger.Info($"Document \"{content.Name}\" (id={content.Id}) cannot be published: document does not have published values."); + Logger.Info(() => $"Document \"{content.Name}\" (id={content.Id}) cannot be published: document does not have published values."); return new PublishResult(PublishResultType.FailedNoPublishedValues, evtMsgs, content); } @@ -2110,15 +2110,15 @@ namespace Umbraco.Core.Services.Implement switch (content.Status) { case ContentStatus.Expired: - Logger.Info($"Document \"{content.Name}\" (id={content.Id}) cannot be published: document has expired."); + Logger.Info(() => $"Document \"{content.Name}\" (id={content.Id}) cannot be published: document has expired."); return new PublishResult(PublishResultType.FailedHasExpired, evtMsgs, content); case ContentStatus.AwaitingRelease: - Logger.Info($"Document \"{content.Name}\" (id={content.Id}) cannot be published: document is awaiting release."); + Logger.Info(() => $"Document \"{content.Name}\" (id={content.Id}) cannot be published: document is awaiting release."); return new PublishResult(PublishResultType.FailedAwaitingRelease, evtMsgs, content); case ContentStatus.Trashed: - Logger.Info($"Document \"{content.Name}\" (id={content.Id}) cannot be published: document is trashed."); + Logger.Info(() => $"Document \"{content.Name}\" (id={content.Id}) cannot be published: document is trashed."); return new PublishResult(PublishResultType.FailedIsTrashed, evtMsgs, content); } @@ -2130,7 +2130,7 @@ namespace Umbraco.Core.Services.Implement var pathIsOk = content.ParentId == Constants.System.Root || IsPathPublished(GetParent(content)); if (pathIsOk == false) { - Logger.Info($"Document \"{content.Name}\" (id={content.Id}) cannot be published: parent is not published."); + Logger.Info(() => $"Document \"{content.Name}\" (id={content.Id}) cannot be published: parent is not published."); return new PublishResult(PublishResultType.FailedPathNotPublished, evtMsgs, content); } @@ -2154,7 +2154,7 @@ namespace Umbraco.Core.Services.Implement // change state to publishing ((Content) content).PublishedState = PublishedState.Publishing; - Logger.Info($"Content \"{content.Name}\" (id={content.Id}) has been published."); + Logger.Info(() => $"Content \"{content.Name}\" (id={content.Id}) has been published."); return result; } @@ -2164,7 +2164,7 @@ namespace Umbraco.Core.Services.Implement // raise UnPublishing event if (scope.Events.DispatchCancelable(UnPublishing, this, new PublishEventArgs(content, evtMsgs))) { - Logger.Info($"Document \"{content.Name}\" (id={content.Id}) cannot be unpublished: unpublishing was cancelled."); + Logger.Info(() => $"Document \"{content.Name}\" (id={content.Id}) cannot be unpublished: unpublishing was cancelled."); return new UnpublishResult(UnpublishResultType.FailedCancelledByEvent, evtMsgs, content); } @@ -2187,13 +2187,13 @@ namespace Umbraco.Core.Services.Implement if (content.ReleaseDate.HasValue && content.ReleaseDate.Value <= DateTime.Now) { content.ReleaseDate = null; - Logger.Info($"Document \"{content.Name}\" (id={content.Id}) had its release date removed, because it was unpublished."); + Logger.Info(() => $"Document \"{content.Name}\" (id={content.Id}) had its release date removed, because it was unpublished."); } // change state to unpublishing ((Content) content).PublishedState = PublishedState.Unpublishing; - Logger.Info($"Document \"{content.Name}\" (id={content.Id}) has been unpublished."); + Logger.Info(() => $"Document \"{content.Name}\" (id={content.Id}) has been unpublished."); return attempt; } diff --git a/src/Umbraco.Web/Editors/AuthenticationController.cs b/src/Umbraco.Web/Editors/AuthenticationController.cs index 50cad49657..493458cc58 100644 --- a/src/Umbraco.Web/Editors/AuthenticationController.cs +++ b/src/Umbraco.Web/Editors/AuthenticationController.cs @@ -406,7 +406,7 @@ namespace Umbraco.Web.Editors var lockedOut = await UserManager.IsLockedOutAsync(model.UserId); if (lockedOut) { - Logger.Info( + Logger.Info(() => $"User {model.UserId} is currently locked out, unlocking and resetting AccessFailedCount"); //var user = await UserManager.FindByIdAsync(model.UserId); @@ -445,7 +445,7 @@ namespace Umbraco.Web.Editors Core.Constants.Security.BackOfficeAuthenticationType, Core.Constants.Security.BackOfficeExternalAuthenticationType); - Logger.Info($"User {(User.Identity == null ? "UNKNOWN" : User.Identity.Name)} from IP address {owinContext.Request.RemoteIpAddress} has logged out"); + Logger.Info(() => $"User {(User.Identity == null ? "UNKNOWN" : User.Identity.Name)} from IP address {owinContext.Request.RemoteIpAddress} has logged out"); if (UserManager != null) { diff --git a/src/Umbraco.Web/HealthCheck/HealthCheckResults.cs b/src/Umbraco.Web/HealthCheck/HealthCheckResults.cs index 139072dcfe..f6ab629f4b 100644 --- a/src/Umbraco.Web/HealthCheck/HealthCheckResults.cs +++ b/src/Umbraco.Web/HealthCheck/HealthCheckResults.cs @@ -62,7 +62,7 @@ namespace Umbraco.Web.HealthCheck var checkIsSuccess = result.Value.All(x => x.ResultType == StatusResultType.Success); if (checkIsSuccess) { - Logger.Info($" Checks for '{checkName}' all completed succesfully."); + Logger.Info(() => $" Checks for '{checkName}' all completed succesfully."); } else { @@ -71,7 +71,7 @@ namespace Umbraco.Web.HealthCheck foreach (var checkResult in checkResults) { - Logger.Info($" Result: {checkResult.ResultType}, Message: '{checkResult.Message}'"); + Logger.Info(() => $" Result: {checkResult.ResultType}, Message: '{checkResult.Message}'"); } } } diff --git a/src/Umbraco.Web/Macros/UserControlMacroEngine.cs b/src/Umbraco.Web/Macros/UserControlMacroEngine.cs index c103a4612f..bcafa602bc 100644 --- a/src/Umbraco.Web/Macros/UserControlMacroEngine.cs +++ b/src/Umbraco.Web/Macros/UserControlMacroEngine.cs @@ -31,7 +31,7 @@ namespace Umbraco.Web.Macros // note: we are not setting the 'CurrentNode' property on the control anymore, // as that was an INode which is gone in v8. Use UmbracoContext to access the // current content. - Current.Logger.Info($"Loaded control \"{filename}\" with ID \"{control.ID}\"."); + Current.Logger.Info(() => $"Loaded control \"{filename}\" with ID \"{control.ID}\"."); UpdateControlProperties(control, model); return new MacroContent { Control = control }; diff --git a/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs b/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs index 21b1246726..630d00c95c 100644 --- a/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs +++ b/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs @@ -667,7 +667,7 @@ namespace Umbraco.Web.Scheduling if (_terminating == false) { _terminating = true; - _logger.Info(_logPrefix + "Terminating" + (immediate ? " (immediate)" : "")); + _logger.Info(() => $"{_logPrefix}Terminating{(immediate ? immediate.ToString() : "")}"); onTerminating = true; } } @@ -681,7 +681,7 @@ namespace Umbraco.Web.Scheduling // processing, call the UnregisterObject method, and then return or it can return immediately and complete // processing asynchronously before calling the UnregisterObject method. - _logger.Info(_logPrefix + "Waiting for tasks to complete"); + _logger.Info(() => _logPrefix + "Waiting for tasks to complete"); Shutdown(false, false); // do not accept any more tasks, flush the queue, do not wait // raise the completed event only after the running threading task has completed @@ -700,7 +700,7 @@ namespace Umbraco.Web.Scheduling // immediate parameter is true, the registered object must call the UnregisterObject method before returning; // otherwise, its registration will be removed by the application manager. - _logger.Info(_logPrefix + "Cancelling tasks"); + _logger.Info(() => _logPrefix + "Cancelling tasks"); Shutdown(true, true); // cancel all tasks, wait for the current one to end Terminate(true); } @@ -723,7 +723,7 @@ namespace Umbraco.Web.Scheduling terminatedSource = _terminatedSource; } - _logger.Info(_logPrefix + "Tasks " + (immediate ? "cancelled" : "completed") + ", terminated"); + _logger.Info(() => _logPrefix + "Tasks " + (immediate ? "cancelled" : "completed") + ", terminated"); OnEvent(Terminated, "Terminated"); diff --git a/src/Umbraco.Web/Search/ExamineComponent.cs b/src/Umbraco.Web/Search/ExamineComponent.cs index 278f124344..44cc6d60f1 100644 --- a/src/Umbraco.Web/Search/ExamineComponent.cs +++ b/src/Umbraco.Web/Search/ExamineComponent.cs @@ -91,7 +91,7 @@ namespace Umbraco.Web.Search var registeredIndexers = examineManager.IndexProviders.Values.OfType().Count(x => x.EnableDefaultEventHandler); - profilingLogger.Logger.Info($"Adding examine event handlers for {registeredIndexers} index providers."); + profilingLogger.Logger.Info(() => $"Adding examine event handlers for {registeredIndexers} index providers."); // don't bind event handlers if we're not suppose to listen if (registeredIndexers == 0) @@ -200,7 +200,7 @@ namespace Umbraco.Web.Search var dir = luceneIndexer.GetLuceneDirectory(); if (IndexWriter.IsLocked(dir)) { - logger.Info("Forcing index " + luceneIndexer.Name + " to be unlocked since it was left in a locked state"); + logger.Info(() => $"Forcing index {luceneIndexer.Name} to be unlocked since it was left in a locked state"); IndexWriter.Unlock(dir); } } diff --git a/src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs b/src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs index 04df63a41f..1c827b6e99 100644 --- a/src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs +++ b/src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs @@ -525,11 +525,8 @@ namespace Umbraco.Web.Security.Providers if (member == null) { - Current.Logger.Info( - string.Format( - "Login attempt failed for username {0} from IP address {1}, the user does not exist", - username, - GetCurrentRequestIpAddress())); + Current.Logger.Info(() => + $"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}, the user does not exist" ); return new ValidateUserResult { @@ -539,11 +536,8 @@ namespace Umbraco.Web.Security.Providers if (member.IsApproved == false) { - Current.Logger.Info( - string.Format( - "Login attempt failed for username {0} from IP address {1}, the user is not approved", - username, - GetCurrentRequestIpAddress())); + Current.Logger.Info(() => + $"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}, the user is not approved"); return new ValidateUserResult { @@ -553,11 +547,8 @@ namespace Umbraco.Web.Security.Providers } if (member.IsLockedOut) { - Current.Logger.Info( - string.Format( - "Login attempt failed for username {0} from IP address {1}, the user is locked", - username, - GetCurrentRequestIpAddress())); + Current.Logger.Info(() => + $"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}, the user is locked"); return new ValidateUserResult { @@ -581,19 +572,13 @@ namespace Umbraco.Web.Security.Providers member.IsLockedOut = true; member.LastLockoutDate = DateTime.Now; - Current.Logger.Info( - string.Format( - "Login attempt failed for username {0} from IP address {1}, the user is now locked out, max invalid password attempts exceeded", - username, - GetCurrentRequestIpAddress())); + Current.Logger.Info(() => + $"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}, the user is now locked out, max invalid password attempts exceeded"); } else { - Current.Logger.Info( - string.Format( - "Login attempt failed for username {0} from IP address {1}", - username, - GetCurrentRequestIpAddress())); + Current.Logger.Info(() => + $"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}"); } } else @@ -606,11 +591,8 @@ namespace Umbraco.Web.Security.Providers member.LastLoginDate = DateTime.Now; - Current.Logger.Info( - string.Format( - "Login attempt succeeded for username {0} from IP address {1}", - username, - GetCurrentRequestIpAddress())); + Current.Logger.Info(() => + $"Login attempt succeeded for username {username} from IP address {GetCurrentRequestIpAddress()}"); } //don't raise events for this! It just sets the member dates, if we do raise events this will diff --git a/src/Umbraco.Web/WebServices/ExamineManagementApiController.cs b/src/Umbraco.Web/WebServices/ExamineManagementApiController.cs index 34ffd1426b..39df833645 100644 --- a/src/Umbraco.Web/WebServices/ExamineManagementApiController.cs +++ b/src/Umbraco.Web/WebServices/ExamineManagementApiController.cs @@ -166,7 +166,7 @@ namespace Umbraco.Web.WebServices var msg = ValidateLuceneIndexer(indexerName, out LuceneIndexer indexer); if (msg.IsSuccessStatusCode) { - _logger.Info($"Rebuilding index '{indexerName}'"); + _logger.Info(() => $"Rebuilding index '{indexerName}'"); //remove it in case there's a handler there alraedy indexer.IndexOperationComplete -= Indexer_IndexOperationComplete; @@ -203,7 +203,7 @@ namespace Umbraco.Web.WebServices //ensure it's not listening anymore indexer.IndexOperationComplete -= Indexer_IndexOperationComplete; - _logger.Info($"Rebuilding index '{indexer.Name}' done, {indexer.CommitCount} items committed (can differ from the number of items in the index)"); + _logger.Info(() => $"Rebuilding index '{indexer.Name}' done, {indexer.CommitCount} items committed (can differ from the number of items in the index)"); var cacheKey = "temp_indexing_op_" + indexer.Name; _runtimeCacheProvider.ClearCacheItem(cacheKey);