Skip to content

DataTaskPublisher extension that logs the request and response to the console

License

Notifications You must be signed in to change notification settings

LukasHromadnik/NetworkLogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

DataTaskPublisher extension that logs the request and response to the console

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages