christoff-1992 / AlamofireLogger

Tiny Alamofire plugin that logs requests and responses.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AlamofireLogger

Tiny Alamofire plugin that logs requests and responses.

Examples

✓ Real, real simple, just prints the HTTP method/status code alongside the URL

Alamofire.request("http://myapi.com/users").log().responseJSON { response in
    print(response)
}

// GET http://myapi.com/users
// 200 http://myapi.com/users

✓ Print response bodies, too

Alamofire.request("http://myapi.com/users").log(.verbose).responseJSON { response in
    print(response)
}

// GET http://myapi.com/users
// 200 http://myapi.com/users: "[{"id": "1", "name": "Ricky"}]"

✓ Different logging levels for requests and responses (e.g. you might only want to print the body of your requests)

Alamofire.request(.put, "http://myapi.com/user/1", parameters: ["name": "Julian"])
    .logRequest(.verbose)
    .logResponse(.simple)
    .responseJSON { response in
        print(response)
}

// PUT http://myapi.com/user/1: "{"name":"Julian"}"
// 200 http://myapi.com/user/1

Wishlist

  • Additional verbosity levels, formatting options
  • Pretty-printed JSON
  • Protocol-oriented logger types

About

Tiny Alamofire plugin that logs requests and responses.

License:MIT License


Languages

Language:Swift 75.5%Language:Ruby 24.5%