Improve speed and reduce allocations by implementing logger overloads to avoid params [] allocation (#8917)
* Implement logger overloads to avoid params [] allocation * Implement console logger ILogger * Call correct signature * Fix exceptions * Introduce ILogger2 * fix logger reference Co-authored-by: Nathan Woulfe <nathan@nathanw.com.au>
This commit is contained in:
@@ -598,7 +598,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
throw new ArgumentException("Kit content cannot have children.", nameof(kit));
|
||||
// ReSharper restore LocalizableElement
|
||||
|
||||
_logger.Debug<ContentStore>("Set content ID: {KitNodeId}", kit.Node.Id);
|
||||
_logger.Debug<ContentStore,int>("Set content ID: {KitNodeId}", kit.Node.Id);
|
||||
|
||||
// get existing
|
||||
_contentNodes.TryGetValue(kit.Node.Id, out var link);
|
||||
@@ -863,7 +863,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
if (link?.Value == null) return false;
|
||||
|
||||
var content = link.Value;
|
||||
_logger.Debug<ContentStore>("Clear content ID: {ContentId}", content.Id);
|
||||
_logger.Debug<ContentStore,int>("Clear content ID: {ContentId}", content.Id);
|
||||
|
||||
// clear the entire branch
|
||||
ClearBranchLocked(content);
|
||||
@@ -1670,7 +1670,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
if (_gen < 0) return;
|
||||
#if DEBUG
|
||||
_logger.Debug<Snapshot>("Dispose snapshot ({Snapshot})", _genRef?.GenObj.Count.ToString() ?? "live");
|
||||
_logger.Debug<Snapshot, string>("Dispose snapshot ({Snapshot})", _genRef?.GenObj.Count.ToString() ?? "live");
|
||||
#endif
|
||||
_gen = -1;
|
||||
if (_genRef != null)
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
throw new InvalidOperationException("Missing cmsContentNu edited content for node " + dto.Id + ", consider rebuilding.");
|
||||
Current.Logger.Warn<DatabaseDataSource>("Missing cmsContentNu edited content for node {NodeId}, consider rebuilding.", dto.Id);
|
||||
Current.Logger.Warn<DatabaseDataSource,int>("Missing cmsContentNu edited content for node {NodeId}, consider rebuilding.", dto.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -236,7 +236,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
throw new InvalidOperationException("Missing cmsContentNu published content for node " + dto.Id + ", consider rebuilding.");
|
||||
Current.Logger.Warn<DatabaseDataSource>("Missing cmsContentNu published content for node {NodeId}, consider rebuilding.", dto.Id);
|
||||
Current.Logger.Warn<DatabaseDataSource,int>("Missing cmsContentNu published content for node {NodeId}, consider rebuilding.", dto.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -131,9 +131,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// stores need to be populated, happens in OnResolutionFrozen which uses _localDbExists to
|
||||
// figure out whether it can read the databases or it should populate them from sql
|
||||
|
||||
_logger.Info<PublishedSnapshotService>("Creating the content store, localContentDbExists? {LocalContentDbExists}", _localContentDbExists);
|
||||
_logger.Info<PublishedSnapshotService,bool>("Creating the content store, localContentDbExists? {LocalContentDbExists}", _localContentDbExists);
|
||||
_contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, _localContentDb);
|
||||
_logger.Info<PublishedSnapshotService>("Creating the media store, localMediaDbExists? {LocalMediaDbExists}", _localMediaDbExists);
|
||||
_logger.Info<PublishedSnapshotService,bool>("Creating the media store, localMediaDbExists? {LocalMediaDbExists}", _localMediaDbExists);
|
||||
_mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, _localMediaDb);
|
||||
}
|
||||
else
|
||||
@@ -182,7 +182,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_localContentDb = BTree.GetTree(localContentDbPath, _localContentDbExists);
|
||||
_localMediaDb = BTree.GetTree(localMediaDbPath, _localMediaDbExists);
|
||||
|
||||
_logger.Info<PublishedSnapshotService>("Registered with MainDom, localContentDbExists? {LocalContentDbExists}, localMediaDbExists? {LocalMediaDbExists}", _localContentDbExists, _localMediaDbExists);
|
||||
_logger.Info<PublishedSnapshotService,bool,bool>("Registered with MainDom, localContentDbExists? {LocalContentDbExists}, localMediaDbExists? {LocalMediaDbExists}", _localContentDbExists, _localMediaDbExists);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -690,7 +690,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
foreach (var payload in payloads)
|
||||
{
|
||||
_logger.Debug<PublishedSnapshotService>("Notified {ChangeTypes} for content {ContentId}", payload.ChangeTypes, payload.Id);
|
||||
_logger.Debug<PublishedSnapshotService,TreeChangeTypes,int>("Notified {ChangeTypes} for content {ContentId}", payload.ChangeTypes, payload.Id);
|
||||
|
||||
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
|
||||
{
|
||||
@@ -783,7 +783,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
foreach (var payload in payloads)
|
||||
{
|
||||
_logger.Debug<PublishedSnapshotService>("Notified {ChangeTypes} for media {MediaId}", payload.ChangeTypes, payload.Id);
|
||||
_logger.Debug<PublishedSnapshotService,TreeChangeTypes,int>("Notified {ChangeTypes} for media {MediaId}", payload.ChangeTypes, payload.Id);
|
||||
|
||||
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
|
||||
{
|
||||
@@ -854,7 +854,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
return;
|
||||
|
||||
foreach (var payload in payloads)
|
||||
_logger.Debug<PublishedSnapshotService>("Notified {ChangeTypes} for {ItemType} {ItemId}", payload.ChangeTypes, payload.ItemType, payload.Id);
|
||||
_logger.Debug<PublishedSnapshotService, ContentTypeChangeTypes, string,int>("Notified {ChangeTypes} for {ItemType} {ItemId}", payload.ChangeTypes, payload.ItemType, payload.Id);
|
||||
|
||||
Notify<IContentType>(_contentStore, payloads, RefreshContentTypesLocked);
|
||||
Notify<IMediaType>(_mediaStore, payloads, RefreshMediaTypesLocked);
|
||||
@@ -938,7 +938,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var idsA = payloads.Select(x => x.Id).ToArray();
|
||||
|
||||
foreach (var payload in payloads)
|
||||
_logger.Debug<PublishedSnapshotService>("Notified {RemovedStatus} for data type {DataTypeId}",
|
||||
_logger.Debug<PublishedSnapshotService, string,int>("Notified {RemovedStatus} for data type {DataTypeId}",
|
||||
payload.Removed ? "Removed" : "Refreshed",
|
||||
payload.Id);
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Umbraco.Web.PublishedCache
|
||||
/// <param name="id">An identifier.</param>
|
||||
public void ClearContentType(int id)
|
||||
{
|
||||
_logger.Debug<PublishedContentTypeCache>("Clear content type w/id {ContentTypeId}", id);
|
||||
_logger.Debug<PublishedContentTypeCache,int>("Clear content type w/id {ContentTypeId}", id);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -107,7 +107,7 @@ namespace Umbraco.Web.PublishedCache
|
||||
/// <param name="id">A data type identifier.</param>
|
||||
public void ClearDataType(int id)
|
||||
{
|
||||
_logger.Debug<PublishedContentTypeCache>("Clear data type w/id {DataTypeId}.", id);
|
||||
_logger.Debug<PublishedContentTypeCache,int>("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
|
||||
|
||||
Reference in New Issue
Block a user