Improve logging performance by checking Trace/Debug log level is enabled (#12793)

This commit is contained in:
Chad
2023-06-07 21:47:05 +12:00
committed by GitHub
parent 9bafdbd992
commit e784cfa960
69 changed files with 648 additions and 224 deletions

View File

@@ -17,8 +17,11 @@ public class PreValueMigratorCollection : BuilderCollectionBase<IPreValueMigrato
public IPreValueMigrator? GetMigrator(string editorAlias)
{
IPreValueMigrator? migrator = this.FirstOrDefault(x => x.CanMigrate(editorAlias));
_logger.LogDebug("Getting migrator for \"{EditorAlias}\" = {MigratorType}", editorAlias,
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
{
_logger.LogDebug("Getting migrator for \"{EditorAlias}\" = {MigratorType}", editorAlias,
migrator == null ? "<null>" : migrator.GetType().Name);
}
return migrator;
}
}