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

@@ -60,7 +60,10 @@ public class PublishedContentTypeCache : IDisposable
/// </summary>
public void ClearAll()
{
_logger.LogDebug("Clear all.");
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
{
_logger.LogDebug("Clear all.");
}
try
{
@@ -84,7 +87,10 @@ public class PublishedContentTypeCache : IDisposable
/// <param name="id">An identifier.</param>
public void ClearContentType(int id)
{
_logger.LogDebug("Clear content type w/id {ContentTypeId}", id);
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
{
_logger.LogDebug("Clear content type w/id {ContentTypeId}", id);
}
try
{
@@ -125,7 +131,10 @@ public class PublishedContentTypeCache : IDisposable
/// <param name="id">A data type identifier.</param>
public void ClearDataType(int id)
{
_logger.LogDebug("Clear data type w/id {DataTypeId}.", id);
if (_logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
{
_logger.LogDebug("Clear data type w/id {DataTypeId}.", id);
}
// there is no recursion to handle here because a PublishedContentType contains *all* its
// properties ie both its own properties and those that were inherited (it's based upon an