Swiftpack.co - LukasHromadnik/NetworkLogger as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by LukasHromadnik.
LukasHromadnik/NetworkLogger 1.0.0
DataTaskPublisher extension that logs the request and response to the console
⭐️ 5
🕓 37 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/LukasHromadnik/NetworkLogger.git", from: "1.0.0")

NetworkLogger

Extension of Combine's DataTaskPublisher that logs the request and response to the console.

Usage

URLSession.shared.dataTaskPublisher(for: url)
    .log()

Then after the Publisher is subscribed the log method prints something like

⬆️ POST https://mysuper.api
Headers: [
    Authorization : Bearer XYZ
]
Body: {
    "key": "value"
}

and when the response comes

⬇️ POST https://mysuper.api (✅ 200 OK)
Headers: [
    Content-Type : application/json
]
Body: {
    "response": {
        "key": 1
    }
}

Inspiration

This library was inspired by Reqres.

License

MIT License

GitHub

link
Stars: 5
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Related Packages

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics