Skip to content

Commit

Permalink
remove .debug and .info from os_log's to avoid future compatibility i…
Browse files Browse the repository at this point in the history
…ssues
  • Loading branch information
simonmcl committed Oct 26, 2023
1 parent 0006374 commit cc3e4cc
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Sources/KukaiCoreSwift/Clients/TezosNodeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public class TezosNodeClient {
dispatchGroup.enter()
dexterQueriesQueue.async { [weak self] in
guard let url = self?.config.primaryNodeURL else {
os_log(.debug, log: .kukaiCoreSwift, "Invalid server url: %@", self?.config.primaryNodeURL.absoluteString ?? "nil")
os_log(.default, log: .kukaiCoreSwift, "Invalid server url: %@", self?.config.primaryNodeURL.absoluteString ?? "nil")
completion(false, KukaiError.internalApplicationError(error: NetworkService.NetworkError.invalidURL))
return
}
Expand All @@ -338,7 +338,7 @@ public class TezosNodeClient {
dispatchGroup.enter()
dexterQueriesQueue.async { [weak self] in
guard let url = self?.config.primaryNodeURL else {
os_log(.debug, log: .kukaiCoreSwift, "Invalid server url: %@", self?.config.primaryNodeURL.absoluteString ?? "nil")
os_log(.default, log: .kukaiCoreSwift, "Invalid server url: %@", self?.config.primaryNodeURL.absoluteString ?? "nil")
completion(false, KukaiError.internalApplicationError(error: NetworkService.NetworkError.invalidURL))
return
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/KukaiCoreSwift/Clients/TzKTClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ public class TzKTClient {
signalrConnection?.on(method: "accounts", callback: { [weak self] argumentExtractor in
do {
let obj = try argumentExtractor.getArgument(type: AccountSubscriptionResponse.self)
os_log("Incoming object parsed: %@", log: .tzkt, type: .debug, "\(obj)")
os_log("Incoming object parsed: %@", log: .tzkt, type: .default, "\(obj)")

if let data = obj.data {
var changedAddress: [String] = []
Expand All @@ -667,7 +667,7 @@ public class TzKTClient {
Close the websocket from `listenForAccountChanges`
*/
public func stopListeningForAccountChanges() {
os_log(.debug, log: .kukaiCoreSwift, "Cancelling listenForAccountChanges")
os_log(.default, log: .kukaiCoreSwift, "Cancelling listenForAccountChanges")
signalrConnection?.stop()
isListening = false
}
Expand Down Expand Up @@ -1098,13 +1098,13 @@ extension TzKTClient: HubConnectionDelegate {
os_log("Subscribe to account changes failed: %@", log: .tzkt, type: .error, "\(error)")
self?.signalrConnection?.stop()
} else {
os_log("Subscribe to account changes succeeded, waiting for objects", log: .tzkt, type: .debug)
os_log("Subscribe to account changes succeeded, waiting for objects", log: .tzkt, type: .default)
}
}
}

public func connectionDidClose(error: Error?) {
os_log("SignalR connection closed: %@", log: .tzkt, type: .debug, String(describing: error))
os_log("SignalR connection closed: %@", log: .tzkt, type: .default, String(describing: error))

if newAddressesToWatch.count > 0 {
self.listenForAccountChanges(addresses: newAddressesToWatch)
Expand Down
2 changes: 1 addition & 1 deletion Sources/KukaiCoreSwift/Services/DiskService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class DiskService {
do {
try data.write(to: fileURL)

os_log(.debug, log: .kukaiCoreSwift, "Serialised encodable to: %@", toFileName)
os_log(.default, log: .kukaiCoreSwift, "Serialised encodable to: %@", toFileName)
return true

} catch (let error) {
Expand Down
42 changes: 21 additions & 21 deletions Sources/KukaiCoreSwift/Services/LedgerService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele

// Register a native function, to be passed into the js functions, that will write chunks of data to the device
let nativeWriteHandler: @convention(block) (String, Int) -> Void = { [weak self] (apdu, expectedNumberOfAPDUs) in
os_log("Inside nativeWriteHandler", log: .ledger, type: .debug)
os_log("Inside nativeWriteHandler", log: .ledger, type: .default)

// Keep track of the number of times its called for each request
self?.counter += 1
Expand Down Expand Up @@ -358,7 +358,7 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele

/// CBCentralManagerDelegate function, must be marked public because of protocol definition
public func centralManagerDidUpdateState(_ central: CBCentralManager) {
os_log("centralManagerDidUpdateState", log: .ledger, type: .debug)
os_log("centralManagerDidUpdateState", log: .ledger, type: .default)
self.bluetoothSetup = (central.state == .poweredOn)
}

Expand All @@ -367,23 +367,23 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele

// If we have been requested to connect to a speicific UUID, only listen for that one and connect immediately if found
if let requested = self.requestedUUID, peripheral.identifier.uuidString == requested {
os_log("Found requested ledger UUID, connecting ...", log: .ledger, type: .debug)
os_log("Found requested ledger UUID, connecting ...", log: .ledger, type: .default)

self.connectedDevice = peripheral
self.centralManager?.connect(peripheral, options: ["requestMTU": 156])
self.centralManager?.stopScan()

// Else if we haven't been requested to find a specific one, store each unique device and fire a delegate callback, until scan stopped manually
} else if self.requestedUUID == nil, deviceList[peripheral.identifier.uuidString] == nil {
os_log("Found a new ledger device. Name: %@, UUID: %@", log: .ledger, type: .debug, peripheral.name ?? "-", peripheral.identifier.uuidString)
os_log("Found a new ledger device. Name: %@, UUID: %@", log: .ledger, type: .default, peripheral.name ?? "-", peripheral.identifier.uuidString)

self.deviceList[peripheral.identifier.uuidString] = peripheral.name ?? ""
}
}

/// CBCentralManagerDelegate function, must be marked public because of protocol definition
public func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
os_log("Connected to %@, %@", log: .ledger, type: .debug, peripheral.name ?? "", peripheral.identifier.uuidString)
os_log("Connected to %@, %@", log: .ledger, type: .default, peripheral.name ?? "", peripheral.identifier.uuidString)

// record the connected device and set LedgerService as the delegate. Don't report successfully connected to ledgerService.delegate until
// we have received the callbacks for services and characteristics. Otherwise we can't use the device
Expand All @@ -394,15 +394,15 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele

/// CBCentralManagerDelegate function, must be marked public because of protocol definition
public func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {
os_log("Failed to connect to %@, %@", log: .ledger, type: .debug, peripheral.name ?? "", peripheral.identifier.uuidString)
os_log("Failed to connect to %@, %@", log: .ledger, type: .default, peripheral.name ?? "", peripheral.identifier.uuidString)
self.connectedDevice = nil
self.deviceConnectedPublisher.send(false)
}

/// CBCentralManagerDelegate function, must be marked public because of protocol definition
public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
guard let services = peripheral.services else {
os_log("Unable to locate services for: %@, %@. Error: %@", log: .ledger, type: .debug, peripheral.name ?? "", peripheral.identifier.uuidString, "\(String(describing: error))")
os_log("Unable to locate services for: %@, %@. Error: %@", log: .ledger, type: .default, peripheral.name ?? "", peripheral.identifier.uuidString, "\(String(describing: error))")
self.connectedDevice = nil
self.deviceConnectedPublisher.send(false)
return
Expand All @@ -419,24 +419,24 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele
/// CBCentralManagerDelegate function, must be marked public because of protocol definition
public func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
guard let characteristics = service.characteristics else {
os_log("Unable to locate characteristics for: %@, %@. Error: %@", log: .ledger, type: .debug, peripheral.name ?? "", peripheral.identifier.uuidString, "\(String(describing: error))")
os_log("Unable to locate characteristics for: %@, %@. Error: %@", log: .ledger, type: .default, peripheral.name ?? "", peripheral.identifier.uuidString, "\(String(describing: error))")
self.connectedDevice = nil
self.deviceConnectedPublisher.send(false)
return
}

for characteristic in characteristics {
if characteristic.uuid == LedgerNanoXConstant.writeUUID {
os_log("Located write characteristic", log: .ledger, type: .debug)
os_log("Located write characteristic", log: .ledger, type: .default)
writeCharacteristic = characteristic

} else if characteristic.uuid == LedgerNanoXConstant.notifyUUID {
os_log("Located notify characteristic", log: .ledger, type: .debug)
os_log("Located notify characteristic", log: .ledger, type: .default)
notifyCharacteristic = characteristic
}

if let _ = writeCharacteristic, let notify = notifyCharacteristic {
os_log("Registering for notifications on notify characteristic", log: .ledger, type: .debug)
os_log("Registering for notifications on notify characteristic", log: .ledger, type: .default)
peripheral.setNotifyValue(true, for: notify)

self.deviceConnectedPublisher.send(true)
Expand All @@ -448,11 +448,11 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele
/// CBCentralManagerDelegate function, must be marked public because of protocol definition
public func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?) {
if let err = error {
os_log("Error during write: %@", log: .ledger, type: .debug, "\( err )")
os_log("Error during write: %@", log: .ledger, type: .default, "\( err )")
returnErrorToPublisher(statusCode: GeneralErrorCodes.UNKNOWN.rawValue)

} else {
os_log("Successfully wrote to write characteristic", log: .ledger, type: .debug)
os_log("Successfully wrote to write characteristic", log: .ledger, type: .default)
}
}

Expand All @@ -462,7 +462,7 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele
return
}

os_log("Receiveing value from notify characteristic", log: .ledger, type: .debug)
os_log("Receiveing value from notify characteristic", log: .ledger, type: .default)


// Extract the payload, convert it to an APDU so the result can be extracted
Expand All @@ -486,7 +486,7 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele


if resultString.count <= 6 {
os_log("Received APDU Status code", log: .ledger, type: .debug)
os_log("Received APDU Status code", log: .ledger, type: .default)
receivedAPDU_statusCode.send(resultString)

if resultString == LedgerService.successCode {
Expand All @@ -496,7 +496,7 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele
return

} else {
os_log("Received APDU Payload", log: .ledger, type: .debug)
os_log("Received APDU Payload", log: .ledger, type: .default)
receivedAPDU_payload.send(resultString)
return
}
Expand Down Expand Up @@ -550,12 +550,12 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele

guard let res = try? concatenatedResult.get() else {
let error = (try? concatenatedResult.getError()) ?? KukaiError.unknown()
os_log("setupWriteSubject - received error: %@", log: .ledger, type: .debug, "\(error)")
os_log("setupWriteSubject - received error: %@", log: .ledger, type: .default, "\(error)")
self.returnKukaiErrorToPublisher(kukaiError: error)
return
}

os_log("setupWriteSubject - received value: %@", log: .ledger, type: .debug, "\( res )")
os_log("setupWriteSubject - received value: %@", log: .ledger, type: .default, "\( res )")
switch self.requestType {
case .address:
self.convertAPDUToAddress(payload: res)
Expand Down Expand Up @@ -588,7 +588,7 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele
if component != "" {
let data = (try? Data(hexString: component)) ?? Data()

os_log("sendAPDU - writing payload", log: .ledger, type: .debug)
os_log("sendAPDU - writing payload", log: .ledger, type: .default)
self.connectedDevice?.writeValue(data, for: writeCharacteristic, type: .withResponse)
}
}
Expand All @@ -597,7 +597,7 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele
// Listen for responses
self.receivedAPDU_statusCode.sink { statusCode in
if statusCode == LedgerService.successCode {
os_log("sendAPDU - received success statusCode", log: .ledger, type: .debug)
os_log("sendAPDU - received success statusCode", log: .ledger, type: .default)
promise(.success(nil))

} else {
Expand All @@ -610,7 +610,7 @@ public class LedgerService: NSObject, CBPeripheralDelegate, CBCentralManagerDele


self.receivedAPDU_payload.sink { payload in
os_log("sendAPDU - received payload: %@", log: .ledger, type: .debug, payload)
os_log("sendAPDU - received payload: %@", log: .ledger, type: .default, payload)
promise(.success(payload))
}
.store(in: &self.bag_apdu)
Expand Down
6 changes: 3 additions & 3 deletions Sources/KukaiCoreSwift/Services/NetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,17 @@ public class NetworkService {
let dataString = NetworkService.dataToStringStippingMichelsonContractCode(data: responseData)

if isPost {
os_log(.debug, log: .network, "Request Succeeded to: %@ \nRequest Body: %@ \nResponse: %@ \n_", fullURL.absoluteString, payloadString, dataString)
os_log(.default, log: .network, "Request Succeeded to: %@ \nRequest Body: %@ \nResponse: %@ \n_", fullURL.absoluteString, payloadString, dataString)
} else {
os_log(.debug, log: .network, "Request Succeeded to: %@ \nResponse: %@ \n_", fullURL.absoluteString, dataString)
os_log(.default, log: .network, "Request Succeeded to: %@ \nResponse: %@ \n_", fullURL.absoluteString, dataString)
}
}

/// Logging details when a request starts using `os_log` global logging
public static func logRequestStart(loggingConfig: LoggingConfig?, fullURL: URL) {
if !(loggingConfig?.logNetworkFailures ?? false) && !(loggingConfig?.logNetworkSuccesses ?? false) { return }

os_log(.debug, log: .network, "Sending request to: %@", fullURL.absoluteString)
os_log(.default, log: .network, "Sending request to: %@", fullURL.absoluteString)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Sources/KukaiCoreSwift/Services/OperationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class OperationService {
case .success(let hash):

// With a successful Parse, we can continue on to Sign, Preapply (to check for errors) and if no errors, inject the operation
os_log(.debug, log: .kukaiCoreSwift, "Remote parse successful")
os_log(.default, log: .kukaiCoreSwift, "Remote parse successful")
self?.signPreapplyAndInject(wallet: wallet, forgedHash: hash, operationPayload: operationPayload, operationMetadata: operationMetadata, completion: completion)

case .failure(let parseError):
Expand Down
4 changes: 2 additions & 2 deletions Sources/KukaiCoreSwift/Services/TaquitoService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class TaquitoService {

// Assign callback handlers for internal JS promise success and error states
let forgeSuccessHandler: @convention(block) (String) -> Void = { [weak self] (result) in
os_log("JavascriptContext forge successful", log: .taquitoService, type: .debug)
os_log("JavascriptContext forge successful", log: .taquitoService, type: .default)
self?.isForging = false
self?.lastForgeCompletionHandler = nil
completion(Result.success(result))
Expand Down Expand Up @@ -159,7 +159,7 @@ public class TaquitoService {

// Assign callback handlers for internal JS promise success and error states
let parseSuccessHandler: @convention(block) (String) -> Void = { [weak self] (result) in
os_log("JavascriptContext parse successful", log: .taquitoService, type: .debug)
os_log("JavascriptContext parse successful", log: .taquitoService, type: .default)
self?.lastParseCompletionHandler = nil
self?.isParsing = false

Expand Down
2 changes: 1 addition & 1 deletion Sources/KukaiCoreSwift/Services/TorusAuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public class TorusAuthService: NSObject {
Task { @MainActor in
do {
let data = try await torus.triggerLogin()
os_log("Torus returned succesful data", log: .torus, type: .debug)
os_log("Torus returned succesful data", log: .torus, type: .default)

var username: String? = nil
var userId: String? = nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/KukaiCoreSwift/Services/WalletCacheService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public class WalletCacheService {
*/
public func readFromDiskAndDecrypt() -> [String: Wallet]? {
guard let data = DiskService.readData(fromFileName: WalletCacheService.sensitiveCacheFileName) else {
os_log(.info, log: .walletCache, "readFromDiskAndDecrypt - no cache file found, returning empty")
os_log(.default, log: .walletCache, "readFromDiskAndDecrypt - no cache file found, returning empty")
return [:] // No such file
}

Expand Down

0 comments on commit cc3e4cc

Please sign in to comment.