From 0a33fd98cca2d50f1f9f63d89abcc266287ed84e Mon Sep 17 00:00:00 2001 From: ta264 Date: Thu, 27 Feb 2020 21:44:08 +0000 Subject: [PATCH] Lazyload logging --- src/NzbDrone.Core/Datastore/LazyLoaded.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/NzbDrone.Core/Datastore/LazyLoaded.cs b/src/NzbDrone.Core/Datastore/LazyLoaded.cs index c5dbde360..91ff44c82 100644 --- a/src/NzbDrone.Core/Datastore/LazyLoaded.cs +++ b/src/NzbDrone.Core/Datastore/LazyLoaded.cs @@ -1,4 +1,6 @@ using System; +using NLog; +using NzbDrone.Common.Instrumentation; namespace NzbDrone.Core.Datastore { @@ -74,6 +76,8 @@ namespace NzbDrone.Core.Datastore /// The child entity that is being lazy loaded. internal class LazyLoaded : LazyLoaded { + private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(LazyLoaded)); + private readonly Func _query; private readonly Func _condition; @@ -115,6 +119,12 @@ namespace NzbDrone.Core.Datastore { if (_condition != null && _condition(_parent)) { + if (SqlBuilderExtensions.LogSql) + { + Logger.Trace($"Lazy loading {typeof(TChild)} for {typeof(TParent)}"); + Logger.Trace("StackTrace: '{0}'", Environment.StackTrace); + } + _value = _query(_database, _parent); } else