Lazyload logging

pull/6/head
ta264 5 years ago
parent b50b0a1411
commit 0a33fd98cc

@ -1,4 +1,6 @@
using System; using System;
using NLog;
using NzbDrone.Common.Instrumentation;
namespace NzbDrone.Core.Datastore namespace NzbDrone.Core.Datastore
{ {
@ -74,6 +76,8 @@ namespace NzbDrone.Core.Datastore
/// <typeparam name="TChild">The child entity that is being lazy loaded.</typeparam> /// <typeparam name="TChild">The child entity that is being lazy loaded.</typeparam>
internal class LazyLoaded<TParent, TChild> : LazyLoaded<TChild> internal class LazyLoaded<TParent, TChild> : LazyLoaded<TChild>
{ {
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(LazyLoaded<TParent, TChild>));
private readonly Func<IDatabase, TParent, TChild> _query; private readonly Func<IDatabase, TParent, TChild> _query;
private readonly Func<TParent, bool> _condition; private readonly Func<TParent, bool> _condition;
@ -115,6 +119,12 @@ namespace NzbDrone.Core.Datastore
{ {
if (_condition != null && _condition(_parent)) 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); _value = _query(_database, _parent);
} }
else else

Loading…
Cancel
Save