From 8485f393ddf89e86576fe70fcec4807ae9fda52a Mon Sep 17 00:00:00 2001 From: "Jimmy W. Hough Jr" Date: Sun, 29 Dec 2024 05:25:51 -0600 Subject: [PATCH] different logging --- Sources/Request/Request/Request.swift | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Sources/Request/Request/Request.swift b/Sources/Request/Request/Request.swift index d329df6..f4c714f 100644 --- a/Sources/Request/Request/Request.swift +++ b/Sources/Request/Request/Request.swift @@ -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()) + ___________________________________ """ }