floggy
floggy copied to clipboard
Pretties up the Dio Logger
"fixes" #47 in that it now logs json body like this:
[DioLoggy] 👻 12:54:29.888400 INFO -
╔╣ Request ║ POST
║ https://jsonplaceholder.typicode.com/posts
╚══════════════════════════════════════════════════════════════════════════════════════════╝
╔ Headers
╟ content-type: application/json; charset=utf-8
╟ contentType: application/json; charset=utf-8
╟ responseType: ResponseType.json
╟ followRedirects: true
╟ connectTimeout: 0
╟ receiveTimeout: 0
╚══════════════════════════════════════════════════════════════════════════════════════════╝
╔ Body
║
║ {
║ title: "foo",
║ body: "bar",
║ userId: 1
║ }
║
╚══════════════════════════════════════════════════════════════════════════════════════════╝
[DioLoggy] 👻 12:54:30.892621 INFO -
╔╣ Response ║ POST ║ Status: 201 Created
║ https://jsonplaceholder.typicode.com/posts
╚══════════════════════════════════════════════════════════════════════════════════════════╝
╔ Headers
╟ x-ratelimit-reset: [1641988503]
╟ date: [Wed, 12 Jan 2022 11:54:29 GMT]
╟ x-ratelimit-limit: [1000]
╟ vary: [Origin, X-HTTP-Method-Override, Accept-Encoding]
╟ x-ratelimit-remaining: [999]
╟ access-control-expose-headers: [Location]
╟ pragma: [no-cache]
╟ server: [cloudflare]
╟ location: [http://jsonplaceholder.typicode.com/posts/101]
╟ content-length: [65]
╟ cf-ray: [6cc630bbfa5341b6-AMS]
╟ etag: [W/"41-GDNaWfnVU6RZhpLbye0veBaqcHA"]
╟ connection: [keep-alive]
╟ cache-control: [no-cache]
╟ cf-cache-status: [DYNAMIC]
╟ report-to:
║ [{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=%2FNPO8eggdK3EpXqga6el
║ G8jnUrZE9X4Wm8r3ZFpXokBCz3FIYH4QAPPr2UmaQMAR2aGaX6JldsTFtbsRiLsBZG6TKn3qpB6gn56Rp5F3uVunKY
║ RqI0uljsTbmRcJn0M6sf4YKiPWT%2BUpJg5AcdKc"}],"group":"cf-nel","max_age":604800}]
╟ content-type: [application/json; charset=utf-8]
╟ expect-ct:
║ [max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"]
╟ access-control-allow-credentials: [true]
╟ x-powered-by: [Express]
╟ alt-svc:
║ [h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=864
║ 00]
╟ nel: [{"success_fraction":0,"report_to":"cf-nel","max_age":604800}]
╟ via: [1.1 vegur]
╟ x-content-type-options: [nosniff]
╟ expires: [-1]
╚══════════════════════════════════════════════════════════════════════════════════════════╝
╔ Body
║
║ {
║ title: "foo",
║ body: "bar",
║ userId: 1,
║ id: 101
║ }
║
╚══════════════════════════════════════════════════════════════════════════════════════════╝
Also adds a the above post request to a button in the example app.
Hey, thanks for PR. I'll go over it next week. But few things I would change now just from example output you showed:
We have IntelliJ auto-collapsing added (There is a gif in readme). This will break that a bit with new character ╟
And with addition to headers collapsed request/response will look like:
[+] [DioLoggy] 👻 12:54:29.888400 INFO -
instead of how it looks now:
[+] [DioLoggy] 👻 12:54:29.888400 INFO - >>> Request | POST | https://jsonplaceholder.typicode.com/posts
I edited the readme to include the 4th character '╟' to not break the AS collapse feature. I also reverted the first line back to show the request/response/error info.
Let me know if you have any more feedback after checking the pr!
How is it going here? Any feedback?
Hey sorry for delay, yeah this look good 😃
Thanks for PR!
Any reason why this isnt merged yet? Would also help me a lot. Thanks
I'm currently running into the same problem on a project I'm working on. Can't pretty log Json/Map, so I thought to make a fix, but I see that this PR already exists. If I can somehow help this PR merge, just let me know, thanks! 😊
Thank you for the PR. We decided to use a different approach to resolve this issue. Please check the latest version of this package v3.1.0.