diff --git a/Package.resolved b/Package.resolved
index 7a2905c..eb9f17c 100644
--- a/Package.resolved
+++ b/Package.resolved
@@ -9,15 +9,6 @@
"version" : "5.10.2"
}
},
- {
- "identity" : "cocoalumberjack",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/CocoaLumberjack/CocoaLumberjack",
- "state" : {
- "revision" : "4b8714a7fb84d42393314ce897127b3939885ec3",
- "version" : "3.8.5"
- }
- },
{
"identity" : "ios-dependency-injection",
"kind" : "remoteSourceControl",
@@ -72,15 +63,6 @@
"version" : "8.42.0"
}
},
- {
- "identity" : "swift-log",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/apple/swift-log",
- "state" : {
- "revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91",
- "version" : "1.6.2"
- }
- },
{
"identity" : "zipfoundation",
"kind" : "remoteSourceControl",
diff --git a/Package.swift b/Package.swift
index e16f1e4..859625f 100644
--- a/Package.swift
+++ b/Package.swift
@@ -21,8 +21,8 @@ if resolveDependenciesForTesting {
let package = Package(
name: "InfomaniakCore",
platforms: [
- .iOS(.v13),
- .macOS(.v10_15)
+ .iOS(.v15),
+ .macOS(.v11)
],
products: [
.library(
@@ -40,7 +40,6 @@ let package = Package(
.package(url: "https://github.com/Alamofire/Alamofire", .upToNextMajor(from: "5.8.0")),
.package(url: "https://github.com/getsentry/sentry-cocoa", .upToNextMajor(from: "8.18.0")),
.package(url: "https://github.com/realm/realm-swift", .upToNextMajor(from: "10.45.0")),
- .package(url: "https://github.com/CocoaLumberjack/CocoaLumberjack", .upToNextMajor(from: "3.8.0")),
.package(url: "https://github.com/weichsel/ZIPFoundation.git", .upToNextMajor(from: "0.9.0")),
.package(url: "https://github.com/MarcoEidinger/OSInfo.git", .upToNextMajor(from: "1.0.0"))
],
@@ -52,8 +51,6 @@ let package = Package(
.product(name: "InfomaniakDI", package: "ios-dependency-injection"),
.product(name: "InfomaniakLogin", package: "ios-login"),
.product(name: "Sentry-Dynamic", package: "sentry-cocoa"),
- .product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
- .product(name: "CocoaLumberjack", package: "CocoaLumberjack"),
.product(name: "OSInfo", package: "OSInfo")
]
),
diff --git a/Sources/InfomaniakCore/Account/KeychainHelper.swift b/Sources/InfomaniakCore/Account/KeychainHelper.swift
index fdc1a85..2655ee5 100644
--- a/Sources/InfomaniakCore/Account/KeychainHelper.swift
+++ b/Sources/InfomaniakCore/Account/KeychainHelper.swift
@@ -16,12 +16,14 @@
along with this program. If not, see .
*/
-import CocoaLumberjackSwift
import Foundation
import InfomaniakLogin
+import OSLog
import Sentry
public class KeychainHelper {
+ private let logger = Logger(category: "KeychainHelper")
+
let accessGroup: String
let tag = "ch.infomaniak.token".data(using: .utf8)!
let keychainQueue = DispatchQueue(label: "com.infomaniak.keychain")
@@ -63,7 +65,7 @@ public class KeychainHelper {
}
return false
} else {
- DDLogInfo("[Keychain] Accessible error ? \(resultCode == noErr), \(resultCode)")
+ logger.error("[Keychain] Accessible error ? \(resultCode == noErr), \(resultCode)")
return false
}
}
@@ -78,7 +80,7 @@ public class KeychainHelper {
kSecValueData as String: lockedValue
]
let resultCode = SecItemAdd(queryAdd as CFDictionary, nil)
- DDLogInfo(
+ logger.info(
"[Keychain] Successfully init KeychainHelper ? \(resultCode == noErr || resultCode == errSecDuplicateItem), \(resultCode)"
)
}
@@ -91,7 +93,7 @@ public class KeychainHelper {
kSecAttrAccount as String: "\(userId)"
]
let resultCode = SecItemDelete(queryDelete as CFDictionary)
- DDLogInfo("Successfully deleted token ? \(resultCode == noErr)")
+ logger.info("Successfully deleted token ? \(resultCode == noErr)")
}
}
@@ -102,7 +104,7 @@ public class KeychainHelper {
kSecAttrService as String: tag
]
let resultCode = SecItemDelete(queryDelete as CFDictionary)
- DDLogInfo("Successfully deleted all tokens ? \(resultCode == noErr)")
+ logger.info("Successfully deleted all tokens ? \(resultCode == noErr)")
}
}
@@ -132,12 +134,12 @@ public class KeychainHelper {
let newTokenExpirationDate = token.expirationDate,
savedTokenExpirationDate <= newTokenExpirationDate {
resultCode = SecItemUpdate(queryUpdate as CFDictionary, attributes as CFDictionary)
- DDLogInfo("Successfully updated token ? \(resultCode == noErr)")
+ logger.info("Successfully updated token ? \(resultCode == noErr)")
SentrySDK.addBreadcrumb(token.generateBreadcrumb(level: .info, message: "Successfully updated token"))
} else if savedToken.expirationDate == nil || token.expirationDate == nil {
// Or if one of them is now an infinite refresh token
resultCode = SecItemUpdate(queryUpdate as CFDictionary, attributes as CFDictionary)
- DDLogInfo("Successfully updated unlimited token ? \(resultCode == noErr)")
+ logger.info("Successfully updated unlimited token ? \(resultCode == noErr)")
SentrySDK.addBreadcrumb(token.generateBreadcrumb(
level: .info,
message: "Successfully updated unlimited token"
@@ -156,7 +158,7 @@ public class KeychainHelper {
kSecValueData as String: tokenData
]
resultCode = SecItemAdd(queryAdd as CFDictionary, nil)
- DDLogInfo("Successfully saved token ? \(resultCode == noErr)")
+ logger.info("Successfully saved token ? \(resultCode == noErr)")
SentrySDK.addBreadcrumb(token.generateBreadcrumb(level: .info, message: "Successfully saved token"))
}
}
@@ -215,7 +217,7 @@ public class KeychainHelper {
let resultCode = withUnsafeMutablePointer(to: &result) {
SecItemCopyMatching(query as CFDictionary, UnsafeMutablePointer($0))
}
- DDLogInfo("Successfully loaded tokens ? \(resultCode == noErr)")
+ logger.info("Successfully loaded tokens ? \(resultCode == noErr)")
guard resultCode == noErr else {
let crumb = Breadcrumb(level: .error, category: "Token")
diff --git a/Sources/InfomaniakCore/Account/UserProfileStore.swift b/Sources/InfomaniakCore/Account/UserProfileStore.swift
index 5c031dc..ffebf83 100644
--- a/Sources/InfomaniakCore/Account/UserProfileStore.swift
+++ b/Sources/InfomaniakCore/Account/UserProfileStore.swift
@@ -16,11 +16,13 @@
along with this program. If not, see .
*/
-import CocoaLumberjackSwift
import Foundation
import InfomaniakDI
+import OSLog
public actor UserProfileStore {
+ private let logger = Logger(category: "UserProfileStore")
+
public typealias UserId = Int
let preferencesURL: URL
@@ -65,7 +67,7 @@ public actor UserProfileStore {
try FileManager.default.createDirectory(atPath: preferencesURL.path, withIntermediateDirectories: true)
try usersData.write(to: storeFileURL)
} catch {
- DDLogError("[UserProfileStore] Error saving accounts :\(error)")
+ logger.error("[UserProfileStore] Error saving accounts :\(error)")
}
}
@@ -84,7 +86,7 @@ public actor UserProfileStore {
profiles = savedUsers
} catch {
- DDLogError("[UserProfileStore] Error loading accounts :\(error)")
+ logger.error("[UserProfileStore] Error loading accounts :\(error)")
}
}
}
diff --git a/Sources/InfomaniakCore/Asynchronous/BackgroundExecutor.swift b/Sources/InfomaniakCore/Asynchronous/BackgroundExecutor.swift
index 940dcd9..3d63a52 100644
--- a/Sources/InfomaniakCore/Asynchronous/BackgroundExecutor.swift
+++ b/Sources/InfomaniakCore/Asynchronous/BackgroundExecutor.swift
@@ -16,10 +16,12 @@
along with this program. If not, see .
*/
-import CocoaLumberjackSwift
import Foundation
+import OSLog
public enum BackgroundExecutor {
+ private static let logger = Logger(category: "BackgroundExecutor")
+
public typealias TaskCompletion = () -> Void
public static func executeWithBackgroundTask(_ block: @escaping (@escaping TaskCompletion) -> Void,
onExpired: @escaping () -> Void) {
@@ -28,24 +30,24 @@ public enum BackgroundExecutor {
let group = TolerantDispatchGroup()
group.enter()
#if os(macOS)
- DDLogDebug("Starting task \(taskName) (No expiration handler as we are running on macOS)")
+ logger.debug("Starting task \(taskName) (No expiration handler as we are running on macOS)")
processInfos.performActivity(options: .suddenTerminationDisabled, reason: taskName) {
block {
- DDLogDebug("Ending task \(taskName)")
+ logger.debug("Ending task \(taskName)")
group.leave()
}
group.wait()
}
#else
- DDLogDebug("Starting task \(taskName)")
+ logger.debug("Starting task \(taskName)")
processInfos.performExpiringActivity(withReason: taskName) { expired in
if expired {
onExpired()
- DDLogDebug("Expired task \(taskName)")
+ logger.debug("Expired task \(taskName)")
group.leave()
} else {
block {
- DDLogDebug("Ending task \(taskName)")
+ logger.debug("Ending task \(taskName)")
group.leave()
}
group.wait()
diff --git a/Sources/InfomaniakCore/Asynchronous/TolerantDispatchGroup.swift b/Sources/InfomaniakCore/Asynchronous/TolerantDispatchGroup.swift
index 9ada66c..b7e3fb6 100644
--- a/Sources/InfomaniakCore/Asynchronous/TolerantDispatchGroup.swift
+++ b/Sources/InfomaniakCore/Asynchronous/TolerantDispatchGroup.swift
@@ -16,10 +16,12 @@
along with this program. If not, see .
*/
-import CocoaLumberjackSwift
import Foundation
+import OSLog
public final class TolerantDispatchGroup {
+ private let logger = Logger(category: "TolerantDispatchGroup")
+
let syncQueue: DispatchQueue
private let dispatchGroup = DispatchGroup()
private var callBalancer = 0
@@ -40,7 +42,7 @@ public final class TolerantDispatchGroup {
public func leave() {
syncQueue.sync {
guard callBalancer > 0 else {
- DDLogWarn("TolerantDispatchGroup: Unbalanced call to leave()")
+ logger.warning("TolerantDispatchGroup: Unbalanced call to leave()")
return
}
diff --git a/Sources/InfomaniakCore/CoreLogger.swift b/Sources/InfomaniakCore/CoreLogger.swift
new file mode 100644
index 0000000..506005a
--- /dev/null
+++ b/Sources/InfomaniakCore/CoreLogger.swift
@@ -0,0 +1,26 @@
+/*
+ Infomaniak Core - iOS
+ Copyright (C) 2025 Infomaniak Network SA
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+import Foundation
+import OSLog
+
+extension Logger {
+ init(category: String) {
+ self.init(subsystem: "com.infomaniak.core", category: category)
+ }
+}
diff --git a/Sources/InfomaniakCore/ItemProviderRepresentation/AppGroupPathProvider.swift b/Sources/InfomaniakCore/ItemProviderRepresentation/AppGroupPathProvider.swift
index 58dfb67..aadb974 100644
--- a/Sources/InfomaniakCore/ItemProviderRepresentation/AppGroupPathProvider.swift
+++ b/Sources/InfomaniakCore/ItemProviderRepresentation/AppGroupPathProvider.swift
@@ -16,8 +16,8 @@
along with this program. If not, see .
*/
-import CocoaLumberjackSwift
import Foundation
+import OSLog
/// Something that can provide a set of common URLs within the app group
///
@@ -47,6 +47,8 @@ public protocol AppGroupPathProvidable: AnyObject {
}
public final class AppGroupPathProvider: AppGroupPathProvidable {
+ private let logger = Logger(category: "AppGroupPathProvider")
+
private let fileManager = FileManager.default
private let realmRootPath: String
@@ -116,7 +118,7 @@ public final class AppGroupPathProvider: AppGroupPathProvidable {
ofItemAtPath: groupDirectoryURL.path
)
} catch {
- DDLogError("[AppGroupPathProvider] failed to protect mandatory path :\(error)")
+ logger.error("[AppGroupPathProvider] failed to protect mandatory path :\(error)")
return nil
}