Skip to content

Commit 78f16e6

Browse files
committed
Removed debug logging. Added logging for Keychain-related errors.
1 parent d6f7ae2 commit 78f16e6

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

CCMenu/Source/Miscellaneous/Keychain.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,9 @@ class Keychain {
5050
}
5151

5252
func getPassword(forURL url: URL) throws -> String? {
53-
let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "keychain")
5453
if let password = cache[url.absoluteString] {
55-
logger.log("Using cached password for \(url, privacy: .public)")
5654
return password
5755
}
58-
logger.log("Retrieving password for \(url, privacy: .public) from keychain")
5956
let query = [
6057
kSecClass: kSecClassInternetPassword,
6158
kSecAttrServer: try getOrThrow(error: .missingHostErr) { url.host() },
@@ -65,11 +62,6 @@ class Keychain {
6562
kSecReturnData: true
6663
] as NSDictionary
6764
let password = try getStringForQuery(query)
68-
if let password {
69-
logger.log("Got password (length = \(password.count, privacy: .public))")
70-
} else {
71-
logger.log("Didn't get a password")
72-
}
7365
cache[url.absoluteString] = password
7466
return password
7567
}

CCMenu/Source/Pipeline Window/CCTray Sheets/CCTrayPipelineBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CCTrayPipelineBuilder: ObservableObject {
4949
let newUrl = components.url?.absoluteURL ?? url
5050
try Keychain.standard.setPassword(credential.password, forURL: newUrl.absoluteString)
5151
} catch {
52-
let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "keychain")
52+
let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "application")
5353
logger.error("Error when storing password in keychain: \(error.localizedDescription, privacy: .public)")
5454
}
5555
}

CCMenu/Source/Pipeline Window/GitHub Sheets/GitHubAuthenticator.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import SwiftUI
8+
import os
89

910
@MainActor
1011
class GitHubAuthenticator: ObservableObject {
@@ -122,8 +123,9 @@ class GitHubAuthenticator: ObservableObject {
122123
do {
123124
token = try Keychain.standard.getToken(forService: "GitHub")
124125
} catch {
125-
// TODO: Figure out what to do here – so many errors...
126126
token = nil
127+
let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "application")
128+
logger.error("Error when retrieving token from keychain: \(error.localizedDescription, privacy: .public)")
127129
}
128130
tokenDescription = token ?? ""
129131
}
@@ -134,7 +136,8 @@ class GitHubAuthenticator: ObservableObject {
134136
do {
135137
try Keychain.standard.setToken(token, forService: "GitHub")
136138
} catch {
137-
// TODO: Figure out what to do here – so many errors...
139+
let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "application")
140+
logger.error("Error when storing token in keychain: \(error.localizedDescription, privacy: .public)")
138141
}
139142
}
140143

CCMenu/Source/Server Monitor/CCTrayAPI.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
import Foundation
8-
import os
98

109
struct HTTPCredential {
1110
var user: String
@@ -19,16 +18,11 @@ struct HTTPCredential {
1918
class CCTrayAPI {
2019

2120
static func requestForProjects(url: URL, credential: HTTPCredential?) -> URLRequest {
22-
let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "network")
2321
var request = URLRequest(url: url)
2422

2523
if let credential {
2624
let v = URLRequest.basicAuthValue(user: credential.user, password: credential.password)
2725
request.setValue(v, forHTTPHeaderField: "Authorization")
28-
let redacted = v.replacingOccurrences(of: "[A-Za-z0-9=]", with: "*", options: [.regularExpression])
29-
logger.log("Making request for url \(url, privacy: .public) with authorization \(redacted, privacy: .public)")
30-
} else {
31-
logger.log("Making request for url \(url, privacy: .public)")
3226
}
3327

3428
return request

0 commit comments

Comments
 (0)