         if(status == errSecSuccess) {
             let password = String(NSString(bytes: UnsafeMutableRawPointer(passwordData)!, length: Int(passwordLength), encoding: String.Encoding.utf8.rawValue)!)
             SecKeychainItemFreeContent(nil, passwordData) // free memory
-            NSLog("Blockstack Core wallet password found in keychain")
+            os_log("Blockstack Core wallet password found in keychain", log: log, type: .info)
             return password
         } else {
-            NSLog("Blockstack Core wallet password not found in keychain: \(SecCopyErrorMessageString(status, nil))")
+            os_log("Blockstack Core wallet password not found in keychain: %{public}@", log: log, type: .info, SecCopyErrorMessageString(status, nil) as! CVarArg)
             SecKeychainItemFreeContent(nil, passwordData) // free memory
-            
+
             return createAndStorePasswordInKeychain()
         }
     }
     
     func createAndStorePasswordInKeychain() -> String {
+        os_log("createAndStorePasswordInKeychain", log: log, type: .debug)
         let serviceNameData = (keychainServiceName as NSString).utf8String
         let accountNameData = (keychainAccountName as NSString).utf8String
         

        let proxyPath = Bundle.main.path(forResource: "blockstackProxy", ofType: "")
        let portalPath = Bundle.main.path(forResource: "browser", ofType: "")
        
        NSLog("Portal proxy path: \(proxyPath)")
        NSLog("Portal path: \(portalPath)")
        
        do {
            NSLog("Trying to remove any existing portal code...")
            try FileManager.default.removeItem(atPath: portalRunPath())
        } catch {
            NSLog("Can't remove existing portal code. It probably doesn't exist.")
        }
        
        NSLog("Copying the latest portal code into the portal run path \(portalRunPath())")

        do {
            try FileManager.default.copyItem(atPath: portalPath!, toPath: portalRunPath())
        } catch {
            NSLog("Can't copy Portal code to the run path: \(portalRunPath())")
        }
        
            

            NSStatusBar.system().removeStatusItem(statusItem)
            
            portalProxyProcess.terminate()
            os_log("Blockstack Portal proxy terminated", log: log, type: .default)
            
            corsProxyProcess.terminate()
            os_log("CORS proxy terminated", log: log, type: .default)
            
            stopCoreAPI(terminationHandler: {
                if(terminate) {
                    NSApplication.shared().terminate(self)
                    os_log("Goodbye!", log: self.log, type: .default)
                }
            })
        }
