diff --git a/DemoApp/Sources/Components/AppState.swift b/DemoApp/Sources/Components/AppState.swift index 14de42e12..31f3a9336 100644 --- a/DemoApp/Sources/Components/AppState.swift +++ b/DemoApp/Sources/Components/AppState.swift @@ -188,7 +188,7 @@ final class AppState: ObservableObject { } } else if let pushToken, !pushToken.isEmpty { deferSetDevice = true - log.debug("Deferring push notification setup for token: \(pushToken)") + log.debug("Deferring push notification setup for token:\(pushToken)") } else { log.debug("Clearing up push notification token.") } diff --git a/DemoApp/Sources/Components/Authentication/AuthenticationProvider.swift b/DemoApp/Sources/Components/Authentication/AuthenticationProvider.swift index 3fe249cb9..8a047fdae 100644 --- a/DemoApp/Sources/Components/Authentication/AuthenticationProvider.swift +++ b/DemoApp/Sources/Components/Authentication/AuthenticationProvider.swift @@ -97,7 +97,7 @@ enum AuthenticationProvider { return UserToken(rawValue: tokenResponse.token) } }() - log.debug("Authentication info userId:\(tokenResponse.userId) apiKey:\(tokenResponse.apiKey) token:\(token)") + log.debug("Authentication response: \(tokenResponse)") return token } } diff --git a/DemoApp/Sources/Models/TokenResponse.swift b/DemoApp/Sources/Models/TokenResponse.swift index b7204c0d9..f60c70b5a 100644 --- a/DemoApp/Sources/Models/TokenResponse.swift +++ b/DemoApp/Sources/Models/TokenResponse.swift @@ -3,8 +3,9 @@ // import Foundation +import StreamVideo -struct TokenResponse: Codable { +struct TokenResponse: Codable, ReflectiveStringConvertible { let userId: String let token: String let apiKey: String diff --git a/Sources/StreamVideo/Utils/Logger/Logger.swift b/Sources/StreamVideo/Utils/Logger/Logger.swift index 410d38e77..c4bab274c 100644 --- a/Sources/StreamVideo/Utils/Logger/Logger.swift +++ b/Sources/StreamVideo/Utils/Logger/Logger.swift @@ -558,11 +558,11 @@ extension Data { /// Converts the data into a pretty-printed JSON string. Use only for debug purposes since this operation can be expensive. var debugPrettyPrintedJSON: String { do { - let jsonObject = try JSONSerialization.jsonObject(with: self, options: [.allowFragments]) + let jsonObject = try JSONSerialization.jsonObject(with: self, options: []) let prettyPrintedData = try JSONSerialization.data(withJSONObject: jsonObject, options: [.prettyPrinted]) return String(data: prettyPrintedData, encoding: .utf8) ?? "Error: Data to String decoding failed." } catch { - return "JSON decoding failed with error: \(error)" + return "" } } } diff --git a/Sources/StreamVideo/WebSockets/Client/URLSessionWebSocketEngine.swift b/Sources/StreamVideo/WebSockets/Client/URLSessionWebSocketEngine.swift index 2b179f239..578ca8c7b 100644 --- a/Sources/StreamVideo/WebSockets/Client/URLSessionWebSocketEngine.swift +++ b/Sources/StreamVideo/WebSockets/Client/URLSessionWebSocketEngine.swift @@ -104,7 +104,6 @@ class URLSessionWebSocketEngine: NSObject, WebSocketEngine { private func doRead() { task?.receive { [weak self] result in - log.debug("received new event \(result)", subsystems: .webSocket) guard let self = self, task != nil else { return } @@ -112,12 +111,14 @@ class URLSessionWebSocketEngine: NSObject, WebSocketEngine { switch result { case let .success(message): if case let .data(data) = message { + log.debug("Received webSocket message: \(data.debugPrettyPrintedJSON)", subsystems: .webSocket) self.callbackQueue.async { [weak self] in guard self?.task != nil else { return } self?.delegate?.webSocketDidReceiveMessage(data) } } else if case let .string(string) = message { let messageData = Data(string.utf8) + log.debug("Received webSocket message:\(messageData.debugPrettyPrintedJSON)", subsystems: .webSocket) self.callbackQueue.async { [weak self] in guard self?.task != nil else { return } self?.delegate?.webSocketDidReceiveMessage(messageData) @@ -126,7 +127,7 @@ class URLSessionWebSocketEngine: NSObject, WebSocketEngine { self.doRead() case let .failure(error): - log.error("Failed receiving Web Socket Message", subsystems: .webSocket, error: error) + log.error("Failed while trying to receive webSocket message.", subsystems: .webSocket, error: error) } } }