From 9c4fa50ca1e9c58aff3dca7936e5b9cc2afa7cd8 Mon Sep 17 00:00:00 2001 From: Fernando Fernandes Date: Thu, 12 Dec 2024 12:07:13 +0100 Subject: [PATCH] Fix Swift 6 concurrency errors - Remove the protocol for now, move the isLoggingEnabled to the init --- Sources/ALMA/ALMA+Logging.swift | 20 ++------------------ Sources/ALMA/ALMA+Protocol.swift | 9 --------- Sources/ALMA/ALMA.swift | 22 ++++++++++++++++------ 3 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 Sources/ALMA/ALMA+Protocol.swift diff --git a/Sources/ALMA/ALMA+Logging.swift b/Sources/ALMA/ALMA+Logging.swift index 563426a..e92e285 100644 --- a/Sources/ALMA/ALMA+Logging.swift +++ b/Sources/ALMA/ALMA+Logging.swift @@ -9,22 +9,6 @@ public enum ALMALoggingCategory: String { case error = "ALMA_Error" } -public extension ALMA { - - // MARK: Enable / Disable Logging - - /// Enables / disables logging information via `AppLogger`. - /// - /// When logging is enabled, the output will be available in *Xcode's Console* or - /// in the *macOS Console app*. - /// - /// In the **macOS Console app**, you can filter ALMA's output by - /// `SUBSYSTEM`: `com.backslash-f.ALMA`. - func setLogging(enabled: Bool) { - ALMA.isLoggingEnabled = enabled - } -} - // MARK: - Internal internal extension ALMA { @@ -34,7 +18,7 @@ internal extension ALMA { /// - Parameters: /// - information: The `String` to be logged. /// - category: A member of the `ALMALoggingCategory` enum. - static func log(information: String, category: ALMALoggingCategory) { + func log(information: String, category: ALMALoggingCategory) { guard isLoggingEnabled else { return } @@ -43,7 +27,7 @@ internal extension ALMA { logger.log(information) } - static func logError(_ error: String) { + func logError(_ error: String) { log(information: error, category: .error) } } diff --git a/Sources/ALMA/ALMA+Protocol.swift b/Sources/ALMA/ALMA+Protocol.swift deleted file mode 100644 index 3cff70b..0000000 --- a/Sources/ALMA/ALMA+Protocol.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation - -public protocol ALMAProtocol { - - /// Enables or disables logging. - /// - /// - Parameter enabled: `true` if `ALMA` should output log info; `false` otherwise. - func setLogging(enabled: Bool) -} diff --git a/Sources/ALMA/ALMA.swift b/Sources/ALMA/ALMA.swift index e786272..5419d9a 100644 --- a/Sources/ALMA/ALMA.swift +++ b/Sources/ALMA/ALMA.swift @@ -1,16 +1,26 @@ -public struct ALMA: ALMAProtocol { +public struct ALMA { // MARK: - Properties // MARK: Internal Properties - /// Enables / disables logging output to both *Xcode's Console* and the macOS *Console app*. `true` by default. - internal static var isLoggingEnabled: Bool = true + /// Enables / disables logging information via `AppLogger`. + /// + /// When logging is enabled, the output will be available in *Xcode's Console* or + /// in the *macOS Console app*. + /// + /// In the **macOS Console app**, you can filter ALMA's output by + /// `SUBSYSTEM`: `com.backslash-f.ALMA`. + let isLoggingEnabled: Bool // MARK: - Lifecycle - - public init() { - ALMA.log( + + /// Creates an ``ALMA`` instance. + /// + /// - Parameter isLoggingEnabled: defaults to `true`. + public init(isLoggingEnabled: Bool = true) { + self.isLoggingEnabled = isLoggingEnabled + log( information: "💪🏻 Armored, sharpened, and raring to go!", category: .lifecycle )