Sniffer 1.5.0

Sniffer 1.5.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Kofktu.


Downloads

Total3,026
Week210
Month984

Installs

Apps66
Apps WeekApps This Week 9
Test Targets18
Test WeekTests This week 6
powered by Segment

GitHub

Stars70
Watchers2
Forks8
Issues1
Contributors1
Pull Requests0

Code

Files2
LOCLines of Code 253


Sniffer 1.5.0

  • By
  • Kofktu




  • Automatic networking activity logger
  • intercepting any outgoing requests and incoming responses for debugging purposes.

alt tag

Requirements

  • iOS 8.0+, macOS 10.9+, watchOS 2.0+, tvOS 9.0+
  • Swift 4.0
  • Swift 3.0 (1.0.6)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

for any requests you make via 'URLSession'

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  Sniffer.register() // Register Sniffer to log all requests
  return true
}

for URLSessionConfiguration

let configuration = URLSessionConfiguration.default
Sniffer.enable(in: configuration)

for Custom Deserializer

public protocol BodyDeserializer {
    func deserialize(body: Data) -> String?
}

public final class CustomTextBodyDeserializer: BodyDeserializer {
    public func deserialize(body: Data) -> String? {
        // customization
        return String?
    }
}

Sniffer.register(deserializer: CustomTextBodyDeserializer(), for: ["text/plain"])

If you want to process the logs directly in your application

// Register the handler if you want the log to be handled directly by the application
Sniffer.onLogger = { (log) in
  print(log)
}

References

Authors

Taeun Kim (kofktu), [email protected]

License

Sniffer is available under the MIT license. See the LICENSE file for more info.