Latest 0.1.1
Homepage https://github.com/diegotl/OkLog-Swift
License MIT
Platforms ios 9.0, osx 10.10
Authors

OkLog for iOS and macOS

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.

Build Status

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

OkLog for iOS 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

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.

Request duration

To have the request duration printed in the log you need to tell OkLog right before the request gets executed (this is optional).

OkLog.willSend(request)

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

Latest podspec

{
    "name": "OkLog",
    "version": "0.1.1",
    "homepage": "https://github.com/diegotl/OkLog-Swift",
    "summary": "A network logger for iOS.",
    "swift_version": "4.2",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Diego Trevisan Lara": "[email protected]"
    },
    "source": {
        "git": "https://github.com/diegotl/OkLog-Swift.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/diegotrevisan90",
    "platforms": {
        "ios": "9.0",
        "osx": "10.10"
    },
    "default_subspecs": "Core",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "OkLog/source/core/**/*",
            "dependencies": {
                "SwiftProtobuf": [],
                "GzipSwift": []
            }
        },
        {
            "name": "Alamofire",
            "source_files": "OkLog/source/Alamofire/",
            "dependencies": {
                "OkLog/Core": [],
                "Alamofire": []
            }
        }
    ]
}

Pin It on Pinterest

Share This