Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jguz-pubnub committed Feb 12, 2025
1 parent c5cfc57 commit a4e948f
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 92 deletions.
2 changes: 1 addition & 1 deletion Sources/PubNub/Extensions/URLRequest+PubNub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extension URLRequest {
if let httpBody = httpBody {
debugString += "\(String(data: httpBody, encoding: .utf8) ?? "(Cannot decode `httpBody` as UTF-8 string`)")"
} else {
debugString += "No HTTP body"
debugString += "no HTTP body"
}

return debugString
Expand Down
8 changes: 7 additions & 1 deletion Sources/PubNub/Helpers/Crypto/CryptoModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,13 @@ extension CryptoModule: Hashable {

extension CryptoModule: CustomStringConvertible {
public var description: String {
"Default cryptor: \(defaultCryptor.id), others: \(cryptors.map { $0.id })"
String.formattedDescription(
self,
arguments: [
("defaultCryptor", defaultCryptor.id),
("cryptors", defaultCryptor.id)
]
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ public struct AutomaticRetry: RequestOperator, Hashable, CustomStringConvertible
private extension AutomaticRetry {
static func validate<T>(value: T, using condition: Bool, replaceOnFailure: T, warningMessage message: String) -> T {
guard condition else {
PubNub.log.warn(message); return replaceOnFailure
PubNub.log.warn(
message,
category: LogCategory.pubNub.rawValue
)
return replaceOnFailure
}
return value
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/PubNub/Networking/Request/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ final class Request {

func didFailToMutate(_ urlRequest: URLRequest, with mutatorError: Error) {
PubNub.log.debug(
"Did fail to mutate URL request due to \(mutatorError)",
"Did fail to mutate URL request for \(requestID) due to \(mutatorError)",
category: LogCategory.networking.rawValue
)

Expand Down Expand Up @@ -267,7 +267,7 @@ final class Request {

func didResume(_ task: URLSessionTask) {
PubNub.log.debug(
"Sending HTTP request \(task.requestDescr())",
"Sending HTTP request \(task.requestDescr()) for \(requestID)",
category: LogCategory.networking.rawValue
)
sessionStream?.emitRequest(
Expand All @@ -283,7 +283,7 @@ final class Request {

func didComplete(_ task: URLSessionTask) {
PubNub.log.debug(
"\(requestID) received response with \(task.statusCodeDescr()) " +
"Received response for \(requestID) with \(task.statusCodeDescr()) " +
"content \(dataDescription) " +
"for request URL \(task.currentRequestUrl()))",
category: LogCategory.networking.rawValue
Expand All @@ -303,7 +303,7 @@ final class Request {

func didComplete(_ task: URLSessionTask, with error: Error) {
PubNub.log.debug(
"\(requestID) received response received with \(task.statusCodeDescr()), " +
"Received response for \(requestID) with \(task.statusCodeDescr()), " +
"content: \(dataDescription) " +
"for request URL \(task.currentRequestUrl()))",
category: LogCategory.networking.rawValue
Expand Down
8 changes: 4 additions & 4 deletions Sources/PubNub/Networking/Response/ResponseOperator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ extension Request {
decoder responseDecoder: D,
completion: @escaping (Result<EndpointResponse<D.Payload>, Error>) -> Void
) {
appendResponseCompletion { result in
appendResponseCompletion { [requestID] result in
queue.async {
PubNub.log.debug(
"Deserializing response",
"Deserializing response for \(requestID)",
category: LogCategory.networking.rawValue
)
let deserializationResult = result.flatMap { response in
Expand All @@ -117,12 +117,12 @@ extension Request {
switch deserializationResult {
case .success:
PubNub.log.debug(
"Response deserialized successfully",
"Response deserialized successfully for \(requestID)",
category: LogCategory.networking.rawValue
)
case let .failure(error):
PubNub.log.debug(
"Deserialization of content failed due to \(error)",
"Deserialization of content for \(requestID) failed due to \(error)",
category: LogCategory.networking.rawValue
)
}
Expand Down
Loading

0 comments on commit a4e948f

Please sign in to comment.