Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info for debugDescription #2700

Merged
merged 3 commits into from
Mar 7, 2019
Merged

Add info for debugDescription #2700

merged 3 commits into from
Mar 7, 2019

Conversation

rain2540
Copy link
Contributor

add parameters info for debugDescription of DataResponse and DownloadResponse

add parameters info for debugDescription of DataResponse and DownloadResponse
Copy link
Contributor

@jshier jshier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Sorry it's taken so long, but we definitely want these changes. I end up writing this manually a lot. You can make the code a lot simpler with my suggestions and I think we should print the response body as well.

@@ -88,6 +88,12 @@ extension DataResponse: CustomStringConvertible, CustomDebugStringConvertible {
/// result.
public var debugDescription: String {
let requestDescription = request.map { "\($0.httpMethod!) \($0)" } ?? "nil"
let parameters = { () -> String in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can greatly compact this code, and the naming should reflect the fact that it's the body parameters:

let body = request?.httpBody.map { String(decoding: $0, as: UTF8.self) } ?? "None"
...
[Request Body]: \(body)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your suggestion

@@ -101,6 +107,7 @@ extension DataResponse: CustomStringConvertible, CustomDebugStringConvertible {

return """
[Request]: \(requestDescription)
[Parameters]: \(parameters)
[Response]: \n\(responseDescription)
[Data]: \(data?.description ?? "None")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're adding the "Request Body", you should do the same thing here: generate a String from the response Data and update this field to be [Response Body].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added [Response Body]

@@ -272,6 +279,12 @@ extension DownloadResponse: CustomStringConvertible, CustomDebugStringConvertibl
/// actions, and the response serialization result.
public var debugDescription: String {
let requestDescription = request.map { "\($0.httpMethod!) \($0)" } ?? "nil"
let parameters = { () -> String in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same changes as mentioned earlier.

Copy link
Contributor

@jshier jshier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@jshier jshier added this to the 5.X milestone Mar 7, 2019
@jshier jshier merged commit dd8eff7 into Alamofire:master Mar 7, 2019
@jshier jshier modified the milestones: 5.X, 5.0.0-beta.3 Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants