Skip to content

Commit 5057ec0

Browse files
committed
Clone in CreateContext method
1 parent 437594e commit 5057ec0

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

dotnet/src/webdriver/Internal/Logging/LogContext.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace OpenQA.Selenium.Internal.Logging
3131
/// Represents a logging context that provides methods for creating sub-contexts, retrieving loggers, emitting log messages, and configuring minimum log levels.
3232
/// </summary>
3333
/// <inheritdoc cref="ILogContext"/>
34-
internal class LogContext : ILogContext
34+
internal sealed class LogContext : ILogContext
3535
{
3636
private ConcurrentDictionary<Type, ILogger>? _loggers;
3737

@@ -66,12 +66,7 @@ public ILogContext CreateContext()
6666

6767
public ILogContext CreateContext(LogEventLevel minimumLevel)
6868
{
69-
ConcurrentDictionary<Type, ILogger>? loggers = null;
70-
71-
if (_loggers != null)
72-
{
73-
loggers = new ConcurrentDictionary<Type, ILogger>(_loggers.Select(l => new KeyValuePair<Type, ILogger>(l.Key, new Logger(l.Value.Issuer, minimumLevel))));
74-
}
69+
ConcurrentDictionary<Type, ILogger>? loggers = CloneLoggers(_loggers, minimumLevel);
7570

7671
var context = new LogContext(minimumLevel, this, loggers, Handlers);
7772

0 commit comments

Comments
 (0)