Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public QueryingEnumerable(
_innerEnumerable = innerEnumerable;
_shaper = shaper;
_contextType = contextType;
_logger = logger;
_logger = logger.CloneWithoutInterceptor();
}

public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore/Diagnostics/IDiagnosticsLogger`.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ public interface IDiagnosticsLogger<TLoggerCategory> : IDiagnosticsLogger
/// Holds registered interceptors, if any.
/// </summary>
IInterceptors Interceptors { get; }

IDiagnosticsLogger<TLoggerCategory> CloneWithoutInterceptor();
}
}
27 changes: 27 additions & 0 deletions src/EFCore/Internal/DiagnosticsLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ public DiagnosticsLogger(
Interceptors = interceptors;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
private DiagnosticsLogger(
[NotNull] ILogger logger,
[NotNull] ILoggingOptions loggingOptions,
[NotNull] DiagnosticSource diagnosticSource,
[NotNull] LoggingDefinitions loggingDefinitions)
{
Logger = logger;
Options = loggingOptions;
DiagnosticSource = diagnosticSource;
Definitions = loggingDefinitions;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -86,6 +104,15 @@ public DiagnosticsLogger(
/// </summary>
public virtual LoggingDefinitions Definitions { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual IDiagnosticsLogger<TLoggerCategory> CloneWithoutInterceptor()
=> new DiagnosticsLogger<TLoggerCategory>(Logger, Options, DiagnosticSource, Definitions);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Query/QueryCompilationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public QueryCompilationContext(
Model = dependencies.Model;
ContextOptions = dependencies.ContextOptions;
ContextType = context.GetType();
Logger = dependencies.Logger;
Logger = dependencies.Logger.CloneWithoutInterceptor();

_queryTranslationPreprocessorFactory = dependencies.QueryTranslationPreprocessorFactory;
_queryableMethodTranslatingExpressionVisitorFactory = dependencies.QueryableMethodTranslatingExpressionVisitorFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public void Log<TState>(

public IDisposable BeginScope<TState>(TState state) => null;

public IDiagnosticsLogger<T> CloneWithoutInterceptor()
=> new FakeDiagnosticsLogger<T>();

public virtual LoggingDefinitions Definitions { get; } = new TestRelationalLoggingDefinitions();

public IInterceptors Interceptors { get; }
Expand Down
3 changes: 3 additions & 0 deletions test/EFCore.Specification.Tests/TestUtilities/TestLogger`.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ public class TestLogger<TCategory, TDefinitions> : TestLogger<TDefinitions>, IDi
where TDefinitions : LoggingDefinitions, new()
{
public IInterceptors Interceptors { get; }

public IDiagnosticsLogger<TCategory> CloneWithoutInterceptor()
=> new TestLogger<TCategory, TDefinitions>();
}
}