Skip to content

Commit cf091aa

Browse files
committed
Use swift-log as logging system
1 parent b94b0b4 commit cf091aa

24 files changed

+146
-235
lines changed

OAuth2.xcodeproj/project.pbxproj

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
/* Begin PBXBuildFile section */
1010
0C2F5E5B1DE2DB8500F621E0 /* OAuth2CodeGrantAzure.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C2F5E5A1DE2DB8500F621E0 /* OAuth2CodeGrantAzure.swift */; };
1111
19C919DD1E51CC8000BFC834 /* OAuth2CustomAuthorizer+macOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C919DC1E51CC8000BFC834 /* OAuth2CustomAuthorizer+macOS.swift */; };
12+
5EA7ED3A2E6ED86100124A26 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = 5EA7ED392E6ED86100124A26 /* Logging */; };
13+
5EA7ED3C2E6ED87300124A26 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = 5EA7ED3B2E6ED87300124A26 /* Logging */; };
14+
5EA7ED3E2E6ED87900124A26 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = 5EA7ED3D2E6ED87900124A26 /* Logging */; };
15+
5EA7ED402E6ED87E00124A26 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = 5EA7ED3F2E6ED87E00124A26 /* Logging */; };
1216
6598544E1C5B3C9500237D39 /* OAuth2Authorizer+tvOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6598543F1C5B3B4000237D39 /* OAuth2Authorizer+tvOS.swift */; };
1317
6598544F1C5B3C9C00237D39 /* OAuth2Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEDB8640193FAB9200C4EEA1 /* OAuth2Base.swift */; };
1418
659854501C5B3C9C00237D39 /* OAuth2Requestable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF47D2A1B1E3FDD0057D838 /* OAuth2Requestable.swift */; };
@@ -118,9 +122,6 @@
118122
EEACE1DD1A7E8DF7009BF3A7 /* extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEDB864B19421DAD00C4EEA1 /* extensions.swift */; };
119123
EEACE1DF1A7E8FC1009BF3A7 /* OAuth2CodeGrantFacebook.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEACE1DE1A7E8FC1009BF3A7 /* OAuth2CodeGrantFacebook.swift */; };
120124
EEACE1E01A7E8FC5009BF3A7 /* OAuth2CodeGrantFacebook.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEACE1DE1A7E8FC1009BF3A7 /* OAuth2CodeGrantFacebook.swift */; };
121-
EEAEF10B1CDBCF28001A1C6F /* OAuth2Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEAEF10A1CDBCF28001A1C6F /* OAuth2Logger.swift */; };
122-
EEAEF10C1CDBCF28001A1C6F /* OAuth2Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEAEF10A1CDBCF28001A1C6F /* OAuth2Logger.swift */; };
123-
EEAEF10D1CDBCF28001A1C6F /* OAuth2Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEAEF10A1CDBCF28001A1C6F /* OAuth2Logger.swift */; };
124125
EEB9A97C1D86C34E0022EF66 /* OAuth2Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEB9A97B1D86C34E0022EF66 /* OAuth2Response.swift */; };
125126
EEB9A97D1D86C34E0022EF66 /* OAuth2Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEB9A97B1D86C34E0022EF66 /* OAuth2Response.swift */; };
126127
EEB9A97E1D86C34E0022EF66 /* OAuth2Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEB9A97B1D86C34E0022EF66 /* OAuth2Response.swift */; };
@@ -239,7 +240,6 @@
239240
EE9EBF1A1D775F74003263FC /* OAuth2Securable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2Securable.swift; sourceTree = "<group>"; };
240241
EEAC17A01CAA69110025F84B /* CONTRIBUTORS.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CONTRIBUTORS.md; sourceTree = "<group>"; };
241242
EEACE1DE1A7E8FC1009BF3A7 /* OAuth2CodeGrantFacebook.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2CodeGrantFacebook.swift; sourceTree = "<group>"; };
242-
EEAEF10A1CDBCF28001A1C6F /* OAuth2Logger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2Logger.swift; sourceTree = "<group>"; };
243243
EEB9A97B1D86C34E0022EF66 /* OAuth2Response.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2Response.swift; sourceTree = "<group>"; };
244244
EEB9A97F1D86CD4A0022EF66 /* OAuth2DataLoaderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2DataLoaderTests.swift; sourceTree = "<group>"; };
245245
EEB9A9821D86D36A0022EF66 /* OAuth2RequestPerformer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OAuth2RequestPerformer.swift; sourceTree = "<group>"; };
@@ -263,6 +263,7 @@
263263
isa = PBXFrameworksBuildPhase;
264264
buildActionMask = 2147483647;
265265
files = (
266+
5EA7ED3E2E6ED87900124A26 /* Logging in Frameworks */,
266267
871279812DB152B300A5AF72 /* SwiftKeychain in Frameworks */,
267268
8760AE602E16C78000020465 /* Semaphore in Frameworks */,
268269
);
@@ -272,6 +273,7 @@
272273
isa = PBXFrameworksBuildPhase;
273274
buildActionMask = 2147483647;
274275
files = (
276+
5EA7ED3C2E6ED87300124A26 /* Logging in Frameworks */,
275277
8712797F2DB152AE00A5AF72 /* SwiftKeychain in Frameworks */,
276278
8760AE5E2E16C77C00020465 /* Semaphore in Frameworks */,
277279
);
@@ -281,6 +283,7 @@
281283
isa = PBXFrameworksBuildPhase;
282284
buildActionMask = 2147483647;
283285
files = (
286+
5EA7ED3A2E6ED86100124A26 /* Logging in Frameworks */,
284287
8712797D2DB152A800A5AF72 /* SwiftKeychain in Frameworks */,
285288
8760AE5C2E16C77700020465 /* Semaphore in Frameworks */,
286289
);
@@ -290,6 +293,7 @@
290293
isa = PBXFrameworksBuildPhase;
291294
buildActionMask = 2147483647;
292295
files = (
296+
5EA7ED402E6ED87E00124A26 /* Logging in Frameworks */,
293297
871279832DB152BB00A5AF72 /* SwiftKeychain in Frameworks */,
294298
);
295299
runOnlyForDeploymentPostprocessing = 0;
@@ -355,7 +359,6 @@
355359
EEB9A9821D86D36A0022EF66 /* OAuth2RequestPerformer.swift */,
356360
EEB9A97B1D86C34E0022EF66 /* OAuth2Response.swift */,
357361
EE79F6591BFAA36900746243 /* OAuth2Error.swift */,
358-
EEAEF10A1CDBCF28001A1C6F /* OAuth2Logger.swift */,
359362
65EC05DF1C9050CB00DE9186 /* OAuth2KeychainAccount.swift */,
360363
EE29EABB195A0DB2008882C8 /* OAuth2DebugURLSessionDelegate.swift */,
361364
EE2983741D40BE7600933CDD /* OAuth2AuthorizerUI.swift */,
@@ -661,6 +664,7 @@
661664
packageReferences = (
662665
8712797A2DB151ED00A5AF72 /* XCRemoteSwiftPackageReference "SwiftKeychain" */,
663666
8760AE5A2E16C5E800020465 /* XCRemoteSwiftPackageReference "Semaphore" */,
667+
5EA7ED382E6ED86100124A26 /* XCRemoteSwiftPackageReference "swift-log" */,
664668
);
665669
productRefGroup = EEDB8625193FAAE500C4EEA1 /* Products */;
666670
projectDirPath = "";
@@ -739,7 +743,6 @@
739743
EE9EBF151D775A21003263FC /* OAuth2DataLoader.swift in Sources */,
740744
EE1070361E5C7A4200250586 /* OAuth2CustomAuthorizerUI.swift in Sources */,
741745
87FABDDE2DC9F2DF00E0C67B /* OAuth2Actor.swift in Sources */,
742-
EEAEF10D1CDBCF28001A1C6F /* OAuth2Logger.swift in Sources */,
743746
EE9EBF1D1D775F74003263FC /* OAuth2Securable.swift in Sources */,
744747
659854521C5B3C9C00237D39 /* OAuth2AuthConfig.swift in Sources */,
745748
EEC49F331C9BF22400989A18 /* OAuth2AuthRequest.swift in Sources */,
@@ -754,7 +757,6 @@
754757
buildActionMask = 2147483647;
755758
files = (
756759
EEACE1DD1A7E8DF7009BF3A7 /* extensions.swift in Sources */,
757-
EEAEF10C1CDBCF28001A1C6F /* OAuth2Logger.swift in Sources */,
758760
EE20118D1E44D0BD00913FA7 /* OAuth2DataLoaderSessionTaskDelegate.swift in Sources */,
759761
65EC05E11C9050CB00DE9186 /* OAuth2KeychainAccount.swift in Sources */,
760762
87FABDDF2DC9F2DF00E0C67B /* OAuth2Actor.swift in Sources */,
@@ -798,7 +800,6 @@
798800
buildActionMask = 2147483647;
799801
files = (
800802
EEACE1DC1A7E8DF6009BF3A7 /* extensions.swift in Sources */,
801-
EEAEF10B1CDBCF28001A1C6F /* OAuth2Logger.swift in Sources */,
802803
65EC05E01C9050CB00DE9186 /* OAuth2KeychainAccount.swift in Sources */,
803804
0C2F5E5B1DE2DB8500F621E0 /* OAuth2CodeGrantAzure.swift in Sources */,
804805
DD0CCBAD1C4DC83A0044C4E3 /* OAuth2WebViewController+macOS.swift in Sources */,
@@ -1273,6 +1274,14 @@
12731274
/* End XCConfigurationList section */
12741275

12751276
/* Begin XCRemoteSwiftPackageReference section */
1277+
5EA7ED382E6ED86100124A26 /* XCRemoteSwiftPackageReference "swift-log" */ = {
1278+
isa = XCRemoteSwiftPackageReference;
1279+
repositoryURL = "https://github.com/apple/swift-log.git";
1280+
requirement = {
1281+
kind = upToNextMajorVersion;
1282+
minimumVersion = 1.6.4;
1283+
};
1284+
};
12761285
8712797A2DB151ED00A5AF72 /* XCRemoteSwiftPackageReference "SwiftKeychain" */ = {
12771286
isa = XCRemoteSwiftPackageReference;
12781287
repositoryURL = "https://github.com/slidoapp/SwiftKeychain";
@@ -1292,6 +1301,26 @@
12921301
/* End XCRemoteSwiftPackageReference section */
12931302

12941303
/* Begin XCSwiftPackageProductDependency section */
1304+
5EA7ED392E6ED86100124A26 /* Logging */ = {
1305+
isa = XCSwiftPackageProductDependency;
1306+
package = 5EA7ED382E6ED86100124A26 /* XCRemoteSwiftPackageReference "swift-log" */;
1307+
productName = Logging;
1308+
};
1309+
5EA7ED3B2E6ED87300124A26 /* Logging */ = {
1310+
isa = XCSwiftPackageProductDependency;
1311+
package = 5EA7ED382E6ED86100124A26 /* XCRemoteSwiftPackageReference "swift-log" */;
1312+
productName = Logging;
1313+
};
1314+
5EA7ED3D2E6ED87900124A26 /* Logging */ = {
1315+
isa = XCSwiftPackageProductDependency;
1316+
package = 5EA7ED382E6ED86100124A26 /* XCRemoteSwiftPackageReference "swift-log" */;
1317+
productName = Logging;
1318+
};
1319+
5EA7ED3F2E6ED87E00124A26 /* Logging */ = {
1320+
isa = XCSwiftPackageProductDependency;
1321+
package = 5EA7ED382E6ED86100124A26 /* XCRemoteSwiftPackageReference "swift-log" */;
1322+
productName = Logging;
1323+
};
12951324
8712797C2DB152A800A5AF72 /* SwiftKeychain */ = {
12961325
isa = XCSwiftPackageProductDependency;
12971326
package = 8712797A2DB151ED00A5AF72 /* XCRemoteSwiftPackageReference "SwiftKeychain" */;

OAuth2.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ let package = Package(
3232
dependencies: [
3333
.package(url: "https://github.com/slidoapp/SwiftKeychain.git", .upToNextMinor(from: "2.1.0")),
3434
.package(url: "https://github.com/groue/Semaphore.git", .upToNextMinor(from: "0.1.0"))
35+
.package(url: "https://github.com/apple/swift-log.git", .upToNextMinor(from: "1.6.4"))
3536
],
3637
targets: [
3738
.target(name: "OAuth2",
3839
dependencies: ["Base", "Flows", "DataLoader"]),
39-
.target(name: "Base", dependencies: ["SwiftKeychain", "Semaphore"]),
40+
.target(name: "Base", dependencies: ["SwiftKeychain", "Semaphore", "Logging"]),
4041
.target(name: "macOS", dependencies: [.target(name: "Base")]),
4142
.target(name: "iOS", dependencies: [.target(name: "Base")]),
4243
.target(name: "tvOS", dependencies: [.target(name: "Base")]),

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Need to specify a separate refresh token URI? You can set the `refresh_uri` in t
7171
Need to debug? Use a `.debug` or even a `.trace` logger:
7272

7373
```swift
74-
oauth2.logger = OAuth2DebugLogger(.trace)
74+
oauth2.logger?.logLevel = .trace
7575
```
7676

7777
For more see [advanced settings](#advanced-settings) below.

Sources/Base/OAuth2AuthRequest.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ open class OAuth2AuthRequest {
189189

190190
// add to request body
191191
if oauth2.clientConfig.secretInBody {
192-
oauth2.logger?.debug("OAuth2", msg: "Adding “client_id” and “client_secret” to request body")
192+
oauth2.logger?.debug("Adding “client_id” and “client_secret” to request body")
193193
finalParams["client_id"] = clientId
194194
finalParams["client_secret"] = secret
195195
}
196196

197197
// add Authorization header (if not in body)
198198
else {
199-
oauth2.logger?.debug("OAuth2", msg: "Adding “Authorization” header as “Basic client-key:client-secret”")
199+
oauth2.logger?.debug("Adding “Authorization” header as “Basic client-key:client-secret”")
200200
let pw = "\(clientId.wwwFormURLEncodedString):\(secret.wwwFormURLEncodedString)"
201201
if let utf8 = pw.data(using: oauth2.clientConfig.authStringEncoding) {
202202
req.setValue("Basic \(utf8.base64EncodedString())", forHTTPHeaderField: "Authorization")
@@ -212,13 +212,13 @@ open class OAuth2AuthRequest {
212212
// add custom headers, first from our OAuth2 instance, then our custom ones
213213
if let headers = oauth2.authHeaders {
214214
for (key, val) in headers {
215-
oauth2.logger?.trace("OAuth2", msg: "Overriding “\(key)” header")
215+
oauth2.logger?.trace("Overriding “\(key)” header")
216216
req.setValue(val, forHTTPHeaderField: key)
217217
}
218218
}
219219
if let headers = headers {
220220
for (key, val) in headers {
221-
oauth2.logger?.trace("OAuth2", msg: "Adding custom “\(key)” header")
221+
oauth2.logger?.trace("Adding custom “\(key)” header")
222222
req.setValue(val, forHTTPHeaderField: key)
223223
}
224224
}

Sources/Base/OAuth2Base.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ open class OAuth2Base: OAuth2Securable {
201201

202202
override open func updateFromKeychainItems(_ items: [String: any Sendable]) {
203203
for message in clientConfig.updateFromStorableItems(items) {
204-
logger?.debug("OAuth2", msg: message)
204+
logger?.debug("\(message)")
205205
}
206206
clientConfig.secretInBody = (clientConfig.endpointAuthMethod == OAuth2EndpointAuthMethod.clientSecretPost)
207207
}
@@ -298,7 +298,7 @@ open class OAuth2Base: OAuth2Securable {
298298
public final func didFail(with error: OAuth2Error?) {
299299
var finalError = error
300300
if let error = finalError {
301-
logger?.debug("OAuth2", msg: "\(error)")
301+
logger?.debug("\(error)")
302302
}
303303
else {
304304
finalError = OAuth2Error.requestCancelled
@@ -319,7 +319,7 @@ open class OAuth2Base: OAuth2Securable {
319319
*/
320320
open func abortAuthorization() {
321321
if !abortTask() {
322-
logger?.debug("OAuth2", msg: "Aborting authorization")
322+
logger?.debug("Aborting authorization")
323323
didFail(with: nil)
324324
}
325325
}
@@ -472,7 +472,7 @@ open class OAuth2Base: OAuth2Securable {
472472
guard let state = params["state"] as? String, !state.isEmpty else {
473473
throw OAuth2Error.missingState
474474
}
475-
logger?.trace("OAuth2", msg: "Checking state, got “\(state)”, expecting “\(context.state)")
475+
logger?.trace("Checking state, got “\(state)”, expecting “\(context.state)")
476476
if !context.matchesState(state) {
477477
throw OAuth2Error.invalidState
478478
}

Sources/Base/OAuth2Logger.swift

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)