Skip to content

Commit

Permalink
This replaces os_log "%{PUBLIC}" with "%{public}", updates the projec…
Browse files Browse the repository at this point in the history
…t to version 3.0.0

Signed-off-by: Dan Cunningham <[email protected]>
  • Loading branch information
digitaldan committed Jul 7, 2024
1 parent 343e007 commit bf80673
Show file tree
Hide file tree
Showing 34 changed files with 174 additions and 174 deletions.
28 changes: 14 additions & 14 deletions NotificationService/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NotificationService: UNNotificationServiceExtension {
var notificationActions: [UNNotificationAction] = []
let userInfo = bestAttemptContent.userInfo

os_log("didReceive userInfo %{PUBLIC}@", log: .default, type: .info, userInfo)
os_log("didReceive userInfo %{public}@", log: .default, type: .info, userInfo)

if let title = userInfo["title"] as? String {
bestAttemptContent.title = title
Expand Down Expand Up @@ -54,7 +54,7 @@ class NotificationService: UNNotificationServiceExtension {
}
}
if !notificationActions.isEmpty {
os_log("didReceive registering %{PUBLIC}@ for category %{PUBLIC}@", log: .default, type: .info, notificationActions, category)
os_log("didReceive registering %{public}@ for category %{public}@", log: .default, type: .info, notificationActions, category)
let notificationCategory =
UNNotificationCategory(
identifier: category,
Expand All @@ -67,7 +67,7 @@ class NotificationService: UNNotificationServiceExtension {
let existingCategoryIdentifiers = existingCategories.map(\.identifier)
if !existingCategoryIdentifiers.contains(category) {
var updatedCategories = existingCategories
os_log("handleNotification adding category %{PUBLIC}@", log: .default, type: .info, category)
os_log("handleNotification adding category %{public}@", log: .default, type: .info, category)
updatedCategories.insert(notificationCategory)
UNUserNotificationCenter.current().setNotificationCategories(updatedCategories)
}
Expand All @@ -86,13 +86,13 @@ class NotificationService: UNNotificationServiceExtension {
} else {
downloadAndAttachMedia
}
os_log("handleNotification downloading %{PUBLIC}@", log: .default, type: .info, attachmentURLString)
os_log("handleNotification downloading %{public}@", log: .default, type: .info, attachmentURLString)
downloadHandler(attachmentURL) { attachment in
if let attachment {
os_log("handleNotification attaching %{PUBLIC}@", log: .default, type: .info, attachmentURLString)
os_log("handleNotification attaching %{public}@", log: .default, type: .info, attachmentURLString)
bestAttemptContent.attachments = [attachment]
} else {
os_log("handleNotification could not attach %{PUBLIC}@", log: .default, type: .info, attachmentURLString)
os_log("handleNotification could not attach %{public}@", log: .default, type: .info, attachmentURLString)
}
contentHandler(bestAttemptContent)
}
Expand Down Expand Up @@ -122,7 +122,7 @@ class NotificationService: UNNotificationServiceExtension {
return actionsArray
}
} catch {
os_log("Error parsing actions: %{PUBLIC}@", log: .default, type: .info, error.localizedDescription)
os_log("Error parsing actions: %{public}@", log: .default, type: .info, error.localizedDescription)
}
}
return nil
Expand All @@ -141,7 +141,7 @@ class NotificationService: UNNotificationServiceExtension {
let client = HTTPClient(username: Preferences.username, password: Preferences.username) // lets not always send auth with this
client.downloadFile(url: url) { localURL, response, error in
guard let localURL else {
os_log("Error downloading media %{PUBLIC}@", log: .default, type: .error, error?.localizedDescription ?? "Unknown error")
os_log("Error downloading media %{public}@", log: .default, type: .error, error?.localizedDescription ?? "Unknown error")
completion(nil)
return
}
Expand All @@ -151,7 +151,7 @@ class NotificationService: UNNotificationServiceExtension {

func downloadAndAttachItemImage(attachmentURL: URL, completion: @escaping (UNNotificationAttachment?) -> Void) {
guard let scheme = attachmentURL.scheme else {
os_log("Could not find scheme %{PUBLIC}@", log: .default, type: .info)
os_log("Could not find scheme %{public}@", log: .default, type: .info)
completion(nil)
return
}
Expand All @@ -161,7 +161,7 @@ class NotificationService: UNNotificationServiceExtension {
let client = HTTPClient(username: Preferences.username, password: Preferences.username, alwaysSendBasicAuth: Preferences.alwaysSendCreds)
client.getItem(baseURLs: [Preferences.localUrl, Preferences.remoteUrl], itemName: itemName) { item, error in
guard let item else {
os_log("Could not find item %{PUBLIC}@", log: .default, type: .info, itemName)
os_log("Could not find item %{public}@", log: .default, type: .info, itemName)
completion(nil)
return
}
Expand All @@ -182,19 +182,19 @@ class NotificationService: UNNotificationServiceExtension {
let tempFileURL = tempDirectory.appendingPathComponent(UUID().uuidString)
do {
try imageData.write(to: tempFileURL)
os_log("Image saved to temporary file: %{PUBLIC}@", log: .default, type: .info, tempFileURL.absoluteString)
os_log("Image saved to temporary file: %{public}@", log: .default, type: .info, tempFileURL.absoluteString)
self.attachFile(localURL: tempFileURL, mimeType: mimeType, completion: completion)
return
} catch {
os_log("Failed to write image data to file: %{PUBLIC}@", log: .default, type: .error, error.localizedDescription)
os_log("Failed to write image data to file: %{public}@", log: .default, type: .error, error.localizedDescription)
}
} else {
os_log("Failed to decode base64 string to Data", log: .default, type: .error)
}
}
}
} catch {
os_log("Failed to parse data: %{PUBLIC}@", log: .default, type: .error, error.localizedDescription)
os_log("Failed to parse data: %{public}@", log: .default, type: .error, error.localizedDescription)
}
}
completion(nil)
Expand Down Expand Up @@ -223,7 +223,7 @@ class NotificationService: UNNotificationServiceExtension {
completion(attachment)
return
} catch {
os_log("Failed to create UNNotificationAttachment: %{PUBLIC}@", log: .default, type: .error, error.localizedDescription)
os_log("Failed to create UNNotificationAttachment: %{public}@", log: .default, type: .error, error.localizedDescription)
}
completion(nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class OpenHABSitemapPage: NSObject {
private func sendCommand(_ item: OpenHABItem?, commandToSend command: String?) {
guard let item else { return }

os_log("SitemapPage sending command %{PUBLIC}@ to %{PUBLIC}@", log: OSLog.remoteAccess, type: .info, command.orEmpty, item.name)
os_log("SitemapPage sending command %{public}@ to %{public}@", log: OSLog.remoteAccess, type: .info, command.orEmpty, item.name)
sendCommand?(item, command)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ public class ClientCertificateManager {
kSecValueRef as String: cert!
]
var status = SecItemDelete(deleteCertQuery as NSDictionary)
os_log("SecItemDelete(cert) result=%{PUBLIC}d", log: .default, type: .info, status)
os_log("SecItemDelete(cert) result=%{public}d", log: .default, type: .info, status)
if status == noErr {
let deleteKeyQuery: [String: Any] = [
kSecClass as String: kSecClassKey,
kSecValueRef as String: key!
]
status = SecItemDelete(deleteKeyQuery as NSDictionary)
os_log("SecItemDelete(key) result=%{PUBLIC}d", log: .default, type: .info, status)
os_log("SecItemDelete(key) result=%{public}d", log: .default, type: .info, status)
}

// Figure out which certs in the certificate chain also need to be removed.
Expand All @@ -124,7 +124,7 @@ public class ClientCertificateManager {
]
let status = SecItemDelete(deleteCertQuery as NSDictionary)
let summary = SecCertificateCopySubjectSummary(ct) as String? ?? ""
os_log("SecItemDelete(certChain) %s result=%{PUBLIC}d", log: .default, type: .info, summary, status)
os_log("SecItemDelete(certChain) %s result=%{public}d", log: .default, type: .info, summary, status)
}
}
}
Expand Down Expand Up @@ -198,15 +198,15 @@ public class ClientCertificateManager {
kSecValueRef as String: clientCert!
]
var status = SecItemAdd(addCertQuery as NSDictionary, nil)
os_log("SecItemAdd(cert) result=%{PUBLIC}d", log: .default, type: .info, status)
os_log("SecItemAdd(cert) result=%{public}d", log: .default, type: .info, status)
if status == noErr {
let addKeyQuery: [String: Any] = [
kSecClass as String: kSecClassKey,
kSecAttrIsPermanent as String: true,
kSecValueRef as String: clientKey!
]
status = SecItemAdd(addKeyQuery as NSDictionary, nil)
os_log("SecItemAdd(key) result=%{PUBLIC}d", log: .default, type: .info, status)
os_log("SecItemAdd(key) result=%{public}d", log: .default, type: .info, status)

// Add the cert chain
if let importingCertChain {
Expand All @@ -216,7 +216,7 @@ public class ClientCertificateManager {
kSecValueRef as String: cert
]
status = SecItemAdd(addCertQuery as NSDictionary, nil)
os_log("SecItemAdd(certChain) result=%{PUBLIC}d", log: .default, type: .info, status)
os_log("SecItemAdd(certChain) result=%{public}d", log: .default, type: .info, status)
if status == errSecDuplicateItem {
// Ignore duplicates as there may already be other client certs with an overlapping issuer chain
status = noErr
Expand Down Expand Up @@ -251,7 +251,7 @@ public class ClientCertificateManager {
importingIdentity = identityDictionaries[0][kSecImportItemIdentity as String] as! SecIdentity?
importingCertChain = identityDictionaries[0][kSecImportItemCertChain as String] as! [SecCertificate]?
} else {
os_log("SecPKCS12Import failed; result=%{PUBLIC}d", log: .default, type: .info, status)
os_log("SecPKCS12Import failed; result=%{public}d", log: .default, type: .info, status)
}
return status
}
Expand Down
2 changes: 1 addition & 1 deletion OpenHABCore/Sources/OpenHABCore/Util/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public extension Endpoint {
var components = URLComponents(string: baseURL)
components?.path = path
components?.queryItems = queryItems
os_log("URL: %{PUBLIC}@", log: OSLog.urlComposition, type: .debug, components?.url?.absoluteString ?? "")
os_log("URL: %{public}@", log: OSLog.urlComposition, type: .debug, components?.url?.absoluteString ?? "")
return components?.url
}

Expand Down
6 changes: 3 additions & 3 deletions OpenHABCore/Sources/OpenHABCore/Util/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ public class HTTPClient: NSObject, URLSessionDelegate {
for codingDatum in codingDatas where codingDatum.openHABItem.type != OpenHABItem.ItemType.group {
items.append(codingDatum.openHABItem)
}
os_log("Loaded items to cache: %{PUBLIC}d", log: .networking, type: .info, items.count)
os_log("Loaded items to cache: %{public}d", log: .networking, type: .info, items.count)
}
completion(items, nil)
} catch {
os_log("getItemsInternal ERROR: %{PUBLIC}@", log: .networking, type: .info, String(describing: error))
os_log("getItemsInternal ERROR: %{public}@", log: .networking, type: .info, String(describing: error))
completion(nil, error)
}
}
Expand All @@ -116,7 +116,7 @@ public class HTTPClient: NSObject, URLSessionDelegate {
completion(nil, NSError(domain: "HTTPClient", code: -1, userInfo: [NSLocalizedDescriptionKey: "No data for item"]))
}
} catch {
os_log("getItemsInternal ERROR: %{PUBLIC}@", log: .networking, type: .info, String(describing: error))
os_log("getItemsInternal ERROR: %{public}@", log: .networking, type: .info, String(describing: error))
completion(nil, error)
}
}
Expand Down
16 changes: 8 additions & 8 deletions OpenHABCore/Sources/OpenHABCore/Util/NetworkConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Foundation
import os.log

public func onReceiveSessionTaskChallenge(with challenge: URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?) {
os_log("onReceiveSessionTaskChallenge host:'%{PUBLIC}@'", log: .default, type: .error, challenge.protectionSpace.host)
os_log("onReceiveSessionTaskChallenge host:'%{public}@'", log: .default, type: .error, challenge.protectionSpace.host)
var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling
var credential: URLCredential?

Expand All @@ -26,14 +26,14 @@ public func onReceiveSessionTaskChallenge(with challenge: URLAuthenticationChall
if challenge.protectionSpace.host == localUrl?.host || challenge.protectionSpace.host == remoteUrl?.host || challenge.protectionSpace.host == "home.myopenhab.org" {
credential = URLCredential(user: Preferences.username, password: Preferences.password, persistence: .forSession)
disposition = .useCredential
os_log("HTTP BasicAuth host:'%{PUBLIC}@'", log: .default, type: .error, challenge.protectionSpace.host)
os_log("HTTP BasicAuth host:'%{public}@'", log: .default, type: .error, challenge.protectionSpace.host)
}
}
return (disposition, credential)
}

public func onReceiveSessionChallenge(with challenge: URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?) {
os_log("onReceiveSessionChallenge host:'%{PUBLIC}@'", log: .default, type: .error, challenge.protectionSpace.host)
os_log("onReceiveSessionChallenge host:'%{public}@'", log: .default, type: .error, challenge.protectionSpace.host)
var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling
var credential: URLCredential?

Expand Down Expand Up @@ -154,10 +154,10 @@ public class NetworkConnection {

commandRequest.setValue("text/plain", forHTTPHeaderField: "Content-type")

os_log("Timeout %{PUBLIC}g", log: .default, type: .info, commandRequest.timeoutInterval)
os_log("Timeout %{public}g", log: .default, type: .info, commandRequest.timeoutInterval)
let link = item.link
os_log("OpenHABViewController posting %{PUBLIC}@ command to %{PUBLIC}@", log: .default, type: .info, command ?? "", link)
os_log("%{PUBLIC}@", log: .default, type: .info, commandRequest.debugDescription)
os_log("OpenHABViewController posting %{public}@ command to %{public}@", log: .default, type: .info, command ?? "", link)
os_log("%{public}@", log: .default, type: .info, commandRequest.debugDescription)

return NetworkConnection.shared.manager.request(commandRequest)
.validate()
Expand All @@ -166,7 +166,7 @@ public class NetworkConnection {
case .success:
os_log("Command sent!", log: .remoteAccess, type: .info)
case let .failure(error):
os_log("%{PUBLIC}@ %d", log: .default, type: .error, error.localizedDescription, response.response?.statusCode ?? 0)
os_log("%{public}@ %d", log: .default, type: .error, error.localizedDescription, response.response?.statusCode ?? 0)
}
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@ public class NetworkConnection {
if pageUrl == "" {
return nil
}
os_log("pageUrl = %{PUBLIC}@", log: OSLog.remoteAccess, type: .info, pageUrl)
os_log("pageUrl = %{public}@", log: OSLog.remoteAccess, type: .info, pageUrl)

guard let pageToLoadUrl = URL(string: pageUrl) else { return nil }

Expand Down
Loading

0 comments on commit bf80673

Please sign in to comment.