NetLogger is a library to keep track of all the network requests made by your app. The library can be used to track all HTTP requests (GET
, POST
, PUT
, UPDATE
, HEAD
, etc.) and see details of all the requests made. The details include info like request URL, request & response headers, request and response body, request and response time, round trip duration, etc. amongst other details.
The library can be used for debugging network calls, see the exact url and payload sent or received in the request right from with the app interface. Using the library enables a special debug user interface that can be launched within the app. All the details of the network requests can be viewed within this UI itself. There is no need for the device to be connected to XCode (not even wirelessly!) when debugging network requests.
NetLogger is distributed as a cocoapod, so if you are familiar with using cocoapods this should be a breeze. Include the following in your pod file and do 'pod install' or 'pod update'.
pod 'NetLogger'
For Swift projects, you should also add or uncomment the use_frameworks!
line in your Podfile
use_frameworks!
pod 'NetLogger'
The usage is as simple as including the following lines in your AppDelegate.m
file.
- Import the
NetLogger.h
file in yourAppDelegate.m
#import <NetLogger/NetLogger.h>
- In
application:didFinishLaunchingWithOptions:
method add the following lines.
NetLogger* nl = [NetLogger sharedManager];
[nl show:ALIGN_RIGHT];
That's it. Now run your application, you should see a launch button floating on the right of your app. Clicking this button would launch the NetLogger interface.
Currently, the NetLogger launch button can be shown in either left, right, top or bottom positions. You may use ALIGN_RIGHT
, ALIGN_LEFT
, ALIGN_TOP
or ALIGN_BOTTOM
as you like.
For Swift,
- Import the framework to your
AppDelegate.swift
file.
import NetLogger
- Add the following lines to application
application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)
let nl = NetLogger.sharedManager() as! NetLogger;
nl.show(NetLoggerAlign.ALIGN_RIGHT);
If you like, we have included a small example project that you could quickly try. To run the example project, clone the repo, and run pod install
from the Example directory first.
Click on the above image to see the video or use this link: https://www.youtube.com/watch?v=zNZmZIXn10M
The NetLogger launch button should show up on the right of your app if you enabled the pod properly. The launch button has high z-index so it would typically appear on top of your app at all times, except when you use system dialogs or keyboards. The launch button would become yellow when there is a request in progress.
Clicking the launch button would present the NetLogger interface. The first screen shows you a list of network requests with the time of requests. It also lists the type of request, for e.g. GET
, POST
, PUT
, etc. A circle of color (Yellow, Red or Green) is shown beside each request.
- If the color of the circle is YELLOW - the request is made and response is awaited.
- If the color is RED - the request was made and response is received, however the response code is not HTTP 2XX (200, 201, 202, etc.). The response is likely to be 4XX or 5XX.
- If the color is GREEN - the request was made and response code received is HTTP 2XX.
The list interface is dyanamic and updated whenever the requests are made through the app.
Clicking on a request would show the details of the request. The details would include info like request URL, request & response headers, request and response body, request and response time, round trip duration, etc. amongst other details.
Some common troubleshooting:
- If you are using Google Auth in your app, we suggest doing the auth first and then enabling the NetLogger.
- If you have problems in installalling the pod, you may want to do a
pod update
orpod repo update
The best place to ask for help would be the GitHub issues section. Just post what you need help with and we will get in touch.
If you have any feedback, please do not hesitate to share with us. We plan to update the library from time to time to make it more powerful!
NetLogger is owned and mantained by VersionN Studios. This library is meant for debugging purposes and should not be shipped with the app.
NetLogger is available under the BSD license. See the LICENSE file for more info.
We welcome contributions to NetLogger. Please submit a pull request with details of what you have fixed, added or updated and we should review and merge/discuss as appropriate.