Skip to content

Commit

Permalink
different logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoughjr committed Dec 29, 2024
1 parent 1a58637 commit 8485f39
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Sources/Request/Request/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,24 @@ extension AnyRequest: Equatable {

extension AnyRequest {
public func prettyJson() -> String {

let session = self.buildSession()
let request = session.request
let conf = session.configuration

let session = self.buildSession()
let request = session.request
let conf = session.configuration

guard let method = request.httpMethod,
let url = request.url,
let headers = request.allHTTPHeaderFields,
let jh = Json(headers).stringified,
let body = request.httpBody
else { return ""}

return """
\(request.httpMethod) \(request.url?.absoluteString ?? "")
Headers: \(Json(request.allHTTPHeaderFields).stringified ?? "")
Body: \(request.httpBody?.prettyJSON() ?? "")
Config: \(conf)
\(method.uppercased()) \(url)
Headers: \(jh)
__________________________________
Body: \(body.prettyJSON())
___________________________________
"""

}
Expand Down

0 comments on commit 8485f39

Please sign in to comment.