From 1a1acd809d40cd2e9d0600d22e8559266cb9043e Mon Sep 17 00:00:00 2001 From: tobias <thinkdifferent055@gmail.com> Date: Sun, 19 Dec 2021 20:55:30 +0100 Subject: [PATCH] Add swift-log --- AppleLibs.xcodeproj/project.pbxproj | 25 +++++++++++++++++++- AppleLibs/Network/Requests/DataManager.swift | 5 +++- Package.swift | 6 +++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/AppleLibs.xcodeproj/project.pbxproj b/AppleLibs.xcodeproj/project.pbxproj index 2ac32d9..799d9c1 100644 --- a/AppleLibs.xcodeproj/project.pbxproj +++ b/AppleLibs.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -31,6 +31,7 @@ F6A251BA260B697300132DEC /* Double+Rounded.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6A251B9260B697300132DEC /* Double+Rounded.swift */; }; F6A251BE260B699100132DEC /* String+Html.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6A251BD260B699100132DEC /* String+Html.swift */; }; F6A70E14275D445300C2FB00 /* Date+Create.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6A70E13275D445300C2FB00 /* Date+Create.swift */; }; + F6CCA30A276FC53D00844F92 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = F6CCA309276FC53D00844F92 /* Logging */; }; F6CD575026D246470051B38E /* Float+Rounded.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6CD574F26D246470051B38E /* Float+Rounded.swift */; }; /* End PBXBuildFile section */ @@ -81,6 +82,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F6CCA30A276FC53D00844F92 /* Logging in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -247,6 +249,7 @@ ); name = AppleLibs; packageProductDependencies = ( + F6CCA309276FC53D00844F92 /* Logging */, ); productName = AppleLibs; productReference = F6A25196260B66FF00132DEC /* AppleLibs.framework */; @@ -298,6 +301,7 @@ ); mainGroup = F6A2518C260B66FF00132DEC; packageReferences = ( + F6CCA308276FC53D00844F92 /* XCRemoteSwiftPackageReference "swift-log" */, ); productRefGroup = F6A25197260B66FF00132DEC /* Products */; projectDirPath = ""; @@ -621,6 +625,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + F6CCA308276FC53D00844F92 /* XCRemoteSwiftPackageReference "swift-log" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/apple/swift-log.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + F6CCA309276FC53D00844F92 /* Logging */ = { + isa = XCSwiftPackageProductDependency; + package = F6CCA308276FC53D00844F92 /* XCRemoteSwiftPackageReference "swift-log" */; + productName = Logging; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = F6A2518D260B66FF00132DEC /* Project object */; } diff --git a/AppleLibs/Network/Requests/DataManager.swift b/AppleLibs/Network/Requests/DataManager.swift index b38bbfb..711927a 100644 --- a/AppleLibs/Network/Requests/DataManager.swift +++ b/AppleLibs/Network/Requests/DataManager.swift @@ -7,7 +7,7 @@ // import Foundation -import os.log +import Logging public protocol HttpResponseFilter { @@ -28,6 +28,8 @@ public protocol DataManagerDelegate open class DataManager: NSObject, URLSessionDelegate { + private static let logger = Logger(label: "de.tobias.AppleLibs.requests") + public enum DataManagerError: Error { case authError @@ -93,6 +95,7 @@ open class DataManager: NSObject, URLSessionDelegate @discardableResult open func request(request r: Request, dataMapper: DataMapper? = nil, sender: Any? = nil) async throws -> Any? { let request = delegate?.manipulateRequest(request: r) ?? r + DataManager.logger.info("Requesting \(r)") guard let req: URLRequest = createUrlRequest(request: request) else { throw ResponseError.requestError diff --git a/Package.swift b/Package.swift index 6ad5418..4fd2ddd 100644 --- a/Package.swift +++ b/Package.swift @@ -12,9 +12,15 @@ let package = Package( targets: ["AppleLibs"] ), ], + dependencies: [ + .package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"), + ], targets: [ .target( name: "AppleLibs", + dependencies: [ + .product(name: "Logging", package: "swift-log") + ], path: "AppleLibs" ), .testTarget( -- GitLab