TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Sep 2015 |
SPMSupports SPM | ✗ |
Maintained by Andy Smart.
Automatic Swift network activity logger for iOS or OSX.
Timberjack is a simple, unintrusive network activity logger. Log every request your app makes, or limit to only those using a certain NSURLSession
if you’d prefer. It also works with Alamofire, if that’s your thing.
Note, Timberjack is written in Swift 2.0, so you’ll need Xcode7 to build. If you’re using Swift 1.2, there’s a compatible version on the swift-1.2 branch
NSURLSession
, NSURLConnection
, Alamofire
and pretty much any networking frameworkJSON
responsesTimberjack is installed as an embedded framework, and such requires at least iOS8. If you require iOS7 compatibility, simply drag the Timberjack.swift
file into your own project.
Nice and easy, just register when your app loads, and Timberjack will monitor and log any requests you make via NSURLSession
or NSURLConnection
.
import UIKit
import Timberjack
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Timberjack.register() //Register Timberjack to log all requests
return true
}
}
Due to the way Alamofire uses NSURLSession, you’ll need to do a little more than the standard installation to monitor all requests. The simplest way to do this is to create a subclass of Manager
to handle your requests, then just use this in place of Alamofire.request()
.
import Alamofire
import Timberjack
class HTTPManager: Alamofire.Manager {
static let sharedManager: HTTPManager = {
let configuration = Timberjack.defaultSessionConfiguration()
let manager = HTTPManager(configuration: configuration)
return manager
}()
}
Timberjack has two modes: Verbose and Light. The default style is Verbose
. To change this, just set it appropriately.
Timberjack.logStyle = .Verbose //Either .Verbose, or .Light
MIT, see LICENSE for details.
Open an issue here, or ping me a message on Twitter. Even better, fork this repo and open a pull-request!
Unfortunately, due to a limitation in NSURLProtocol
, Timberjack is unable to log the HTTP body of a request, see This radar for more details
Built by @andyjsmart