diff --git a/Sources/Logging/Logging.swift b/Sources/Logging/Logging.swift index c41f673..36b553a 100644 --- a/Sources/Logging/Logging.swift +++ b/Sources/Logging/Logging.swift @@ -517,7 +517,7 @@ public enum LoggingSystem { /// - parameters: /// - factory: A closure that given a `Logger` identifier, produces an instance of the `LogHandler`. @preconcurrency - public static func bootstrap(_ factory: @escaping @Sendable (String) -> any LogHandler) { + public static func bootstrap(_ factory: @escaping @Sendable(String) -> any LogHandler) { self._factory.replace({ label, _ in factory(label) }, validate: true) @@ -534,14 +534,14 @@ public enum LoggingSystem { /// - metadataProvider: The `MetadataProvider` used to inject runtime-generated metadata from the execution context. /// - factory: A closure that given a `Logger` identifier, produces an instance of the `LogHandler`. @preconcurrency - public static func bootstrap(_ factory: @escaping @Sendable (String, Logger.MetadataProvider?) -> any LogHandler, + public static func bootstrap(_ factory: @escaping @Sendable(String, Logger.MetadataProvider?) -> any LogHandler, metadataProvider: Logger.MetadataProvider?) { self._metadataProviderFactory.replace(metadataProvider, validate: true) self._factory.replace(factory, validate: true) } // for our testing we want to allow multiple bootstrapping - internal static func bootstrapInternal(_ factory: @escaping @Sendable (String) -> any LogHandler) { + internal static func bootstrapInternal(_ factory: @escaping @Sendable(String) -> any LogHandler) { self._metadataProviderFactory.replace(nil, validate: false) self._factory.replace({ label, _ in factory(label) @@ -549,7 +549,7 @@ public enum LoggingSystem { } // for our testing we want to allow multiple bootstrapping - internal static func bootstrapInternal(_ factory: @escaping @Sendable (String, Logger.MetadataProvider?) -> any LogHandler, + internal static func bootstrapInternal(_ factory: @escaping @Sendable(String, Logger.MetadataProvider?) -> any LogHandler, metadataProvider: Logger.MetadataProvider?) { self._metadataProviderFactory.replace(metadataProvider, validate: false) self._factory.replace(factory, validate: false) @@ -594,13 +594,13 @@ public enum LoggingSystem { func withReadLock(_ operation: (Value) -> Result) -> Result { self.lock.withReaderLock { - return operation(self.storage) + operation(self.storage) } } func withWriteLock(_ operation: (inout Value) -> Result) -> Result { self.lock.withWriterLock { - return operation(&self.storage) + operation(&self.storage) } } } @@ -645,7 +645,7 @@ public enum LoggingSystem { } } - private typealias FactoryBox = ReplaceOnceBox<@Sendable (_ label: String, _ provider: Logger.MetadataProvider?) -> any LogHandler> + private typealias FactoryBox = ReplaceOnceBox< @Sendable(_ label: String, _ provider: Logger.MetadataProvider?) -> any LogHandler> private typealias MetadataProviderBox = ReplaceOnceBox } @@ -1103,6 +1103,7 @@ internal struct StdioOutputStream: TextOutputStream, @unchecked Sendable { #endif return StdioOutputStream(file: systemStderr, flushMode: .always) }() + internal static let stdout = { // Prevent name clashes #if canImport(Darwin) diff --git a/Tests/LoggingTests/LoggingTest.swift b/Tests/LoggingTests/LoggingTest.swift index 487b5ff..d9bf9b2 100644 --- a/Tests/LoggingTests/LoggingTest.swift +++ b/Tests/LoggingTests/LoggingTest.swift @@ -22,7 +22,7 @@ import WinSDK import Glibc #endif -fileprivate extension LogHandler { +private extension LogHandler { func with(logLevel: Logger.Level) -> any LogHandler { var result = self result.logLevel = logLevel @@ -711,7 +711,7 @@ class LoggingTest: XCTestCase { private let lock = Lock() private var storage: Value - init(initialValue: Value) { + init(initialValue: Value) { self.storage = initialValue } @@ -721,15 +721,15 @@ class LoggingTest: XCTestCase { } } - func withLockMutating(_ operation: (inout Value) -> Void) -> Void { + func withLockMutating(_ operation: (inout Value) -> Void) { self.lock.withLockVoid { operation(&self.storage) } } var underlying: Value { - get { self.withLock { return $0 } } - set { self.withLockMutating { $0 = newValue }} + get { self.withLock { $0 } } + set { self.withLockMutating { $0 = newValue } } } } diff --git a/Tests/LoggingTests/TestLogger.swift b/Tests/LoggingTests/TestLogger.swift index 0f1b8ec..9cd6dab 100644 --- a/Tests/LoggingTests/TestLogger.swift +++ b/Tests/LoggingTests/TestLogger.swift @@ -364,7 +364,7 @@ internal struct TestLibrary { self.logger.info("TestLibrary::doSomething") } - public func doSomethingAsync(completion: @escaping @Sendable () -> Void) { + public func doSomethingAsync(completion: @escaping @Sendable() -> Void) { // libraries that use global loggers and async, need to make sure they propagate the // logging metadata when creating a new thread let metadata = MDC.global.metadata