Skip to content

Commit efffbfb

Browse files
pinkisemilsrablador
authored andcommitted
Add extra logging and fix comments
1 parent 313472a commit efffbfb

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

ios/MullvadREST/MullvadAPI/MullvadApiNetworkOperation.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ extension REST {
7979
logger.debug("\(#function): \(request.name) API response received")
8080

8181
if let apiError = response.error {
82-
logger.error("Request failed to send error=\(apiError)")
82+
logger
83+
.error(
84+
"Response contained error code \(apiError.statusCode), error: \(apiError.errorDescription)"
85+
)
8386
finish(result: .failure(restError(apiError: apiError)))
8487
return
8588
}

ios/MullvadVPNUITests/MullvadApi.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import Foundation
10+
import MullvadLogging
1011
import MullvadRustRuntime
1112

1213
struct MullvadApiError: Error {
@@ -29,7 +30,10 @@ private struct DeviceResponse: Decodable {
2930
class MullvadApi {
3031
private let context: SwiftApiContext
3132

33+
private static let logger = Logger(label: "MullvadApi")
34+
3235
init(apiAddress: String, hostname: String) throws {
36+
Self.logger.debug("Initializing MullvadApi with address: \(apiAddress), hostname: \(hostname)")
3337
let directRaw = convert_builtin_access_method_setting(
3438
UUID().uuidString, "Direct", true, UInt8(KindDirect.rawValue), nil
3539
)

ios/MullvadVPNUITests/Networking/MullvadAPIWrapper.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import CryptoKit
1010
import Foundation
11+
import MullvadRustRuntime
1112
import XCTest
1213

1314
enum MullvadAPIError: Error {
@@ -32,6 +33,7 @@ class MullvadAPIWrapper: @unchecked Sendable {
3233
.infoDictionary?["ApiEndpoint"] as! String
3334

3435
init() throws {
36+
RustLogging.initialize()
3537
let apiAddress = try Self.getAPIIPAddress() + ":" + Self.getAPIPort()
3638
let hostname = Self.hostName
3739
mullvadAPI = try MullvadApi(apiAddress: apiAddress, hostname: hostname)

mullvad-ios/src/api_client/access_method_settings.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,16 @@ pub unsafe extern "C" fn init_access_method_settings_wrapper(
155155
/// This takes ownership of the `AccessMethodSetting`s pointed to by `raw_array`. So the memory is
156156
/// freed when the returned vector is dropped.
157157
///
158-
/// SAFETY: `raw_array` must be aligned, non-null, initialized for `count` reads and not be used
159-
/// after this call.
158+
/// SAFETY: `raw_array` must be aligned, initialized for `count` reads and not be used after this
159+
/// call.
160160
unsafe fn access_methods_from_raw_array(
161161
raw_array: *const *mut AccessMethodSetting,
162162
number_of_elements: usize,
163163
) -> Vec<AccessMethodSetting> {
164164
// `slice::from_raw_parts` will dereference the null pointer even if the slice is empty.
165165
// In that case, just return an empty vec.
166166
if number_of_elements == 0 || raw_array.is_null() {
167-
return vec![]
167+
return vec![];
168168
}
169169
// SAFETY: See notice above
170170
let slice = unsafe { slice::from_raw_parts(raw_array, number_of_elements) };

0 commit comments

Comments
 (0)