Swiftpack.co - diegotl/OkLog-Swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by diegotl.
diegotl/OkLog-Swift 0.2.4
A network logger for iOS and macOS projects.
⭐️ 18
🕓 1 week ago
iOS macOS
.package(url: "https://github.com/diegotl/OkLog-Swift.git", from: "0.2.4")

OkLog for iOS and macOS

Build Status SPM compatible CocoaPods Compatible codebeat badge Languages

OkLog-Swift is a network logger written in Swift highly inspired by simonpercic's original OkLog implementation to be used in iOS and macOS projects.

What does it do?

OkLog encodes request & response data and generates an URL from where you can see all those info nicely, making it easy to debug and share network data. Here's an example.

Installation

CocoaPods

OkLog is integrated with CocoaPods. To use it in your project, add to your Podfile:

pod 'OkLog'

or

pod 'OkLog/Alamofire'

and then don't forget to run:

$ pod install

Swift Package Manager

OkLog is also available through SPM.

Usage

URLSession

In the URLSession's result closure simply call

OkLog.log(request: request, response: response, data: data)

to get the URL printed in Xcode's console, or

let url = OkLog.getUrl(request: request, response: response, data: data)

to retrieve it and do whatever you want.

Alamofire

If you are using Alamofire, place

OkLog.log(response)

or

let url = OkLog.getUrl(response)

in the request's completion closure.

You can also opt-out from URL shortening by specifying shortenUrl: false as parameter.

An example project is included with a few sample requests using URLSession and Alamofire.

GitHub

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

Release Notes

Removed request duration logic.
2 years ago

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