Skip to content

Commit

Permalink
Make DefaultLoggingCacheTime private (#25422)
Browse files Browse the repository at this point in the history
Part of #24743 (API review)
  • Loading branch information
roji authored Aug 5, 2021
1 parent b008ea8 commit 2053a66
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ public RelationalCommandDiagnosticsLogger(
IInterceptors? interceptors = null)
: base(loggerFactory, loggingOptions, diagnosticSource, loggingDefinitions, contextLogger, interceptors)
{
_loggingCacheTime = contextOptions.FindExtension<CoreOptionsExtension>()?.LoggingCacheTime ??
CoreOptionsExtension.DefaultLoggingCacheTime;
var coreOptionsExtension =
contextOptions.FindExtension<CoreOptionsExtension>()
?? new CoreOptionsExtension();

_loggingCacheTime = coreOptionsExtension.LoggingCacheTime;
}

#region CommandCreating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ public RelationalConnectionDiagnosticsLogger(
IInterceptors? interceptors = null)
: base(loggerFactory, loggingOptions, diagnosticSource, loggingDefinitions, contextLogger, interceptors)
{
_loggingCacheTime = contextOptions.FindExtension<CoreOptionsExtension>()?.LoggingCacheTime ??
CoreOptionsExtension.DefaultLoggingCacheTime;
var coreOptionsExtension =
contextOptions.FindExtension<CoreOptionsExtension>()
?? new CoreOptionsExtension();

_loggingCacheTime = coreOptionsExtension.LoggingCacheTime;
}

#region ConnectionOpening
Expand Down
8 changes: 2 additions & 6 deletions src/EFCore/Infrastructure/CoreOptionsExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@ public class CoreOptionsExtension : IDbContextOptionsExtension
private QueryTrackingBehavior _queryTrackingBehavior = QueryTrackingBehavior.TrackAll;
private Dictionary<(Type, Type?), Type>? _replacedServices;
private int? _maxPoolSize;
private TimeSpan _loggingCacheTime = DefaultLoggingCacheTime;
private TimeSpan _loggingCacheTime = _defaultLoggingCacheTime;
private bool _serviceProviderCachingEnabled = true;
private DbContextOptionsExtensionInfo? _info;
private IEnumerable<IInterceptor>? _interceptors;

/// <summary>
/// The default for how long EF Core will cache logging configuration in certain high-performance paths: one second.
/// See <see cref="DbContextOptionsBuilder.ConfigureLoggingCacheTime" />.
/// </summary>
public static readonly TimeSpan DefaultLoggingCacheTime = TimeSpan.FromSeconds(1);
private static readonly TimeSpan _defaultLoggingCacheTime = TimeSpan.FromSeconds(1);

private WarningsConfiguration _warningsConfiguration
= new WarningsConfiguration()
Expand Down

0 comments on commit 2053a66

Please sign in to comment.