diff --git a/DatadogCore/Sources/Datadog.swift b/DatadogCore/Sources/Datadog.swift index 272f53d588..70740e327d 100644 --- a/DatadogCore/Sources/Datadog.swift +++ b/DatadogCore/Sources/Datadog.swift @@ -231,7 +231,14 @@ public enum Datadog { /// Verbosity level of Datadog SDK. Can be used for debugging purposes. /// If set, internal events occuring inside SDK will be printed to debugger console if their level is equal or greater than `verbosityLevel`. /// Default is `nil`. - public static var verbosityLevel: CoreLoggerLevel? = nil + public static var verbosityLevel: CoreLoggerLevel? { + get { _verbosityLevel.wrappedValue } + set { _verbosityLevel.wrappedValue = newValue } + } + + /// The backing storage for `verbosityLevel`, ensuring efficient synchronized + /// read/write access to the shared value. + private static let _verbosityLevel = ReadWriteLock(wrappedValue: nil) /// Returns `true` if the Datadog SDK is already initialized, `false` otherwise. /// diff --git a/DatadogInternal/Sources/Concurrency/ReadWriteLock.swift b/DatadogInternal/Sources/Concurrency/ReadWriteLock.swift index bb46135609..5093712c7f 100644 --- a/DatadogInternal/Sources/Concurrency/ReadWriteLock.swift +++ b/DatadogInternal/Sources/Concurrency/ReadWriteLock.swift @@ -13,7 +13,7 @@ import Foundation /// An additional method `mutate` allow to safely mutate the value in-place (to read it /// and write it while obtaining the lock only once). @propertyWrapper -public final class ReadWriteLock { +public final class ReadWriteLock: @unchecked Sendable { /// The wrapped value. private var value: Value