Sniffer 1.0.5

Sniffer 1.0.5

DocsDocumented
TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by KofktuSDK.


Downloads

Total194
Week30
Month182

Installs

Apps14
Apps WeekApps This Week 6
Test Targets2
powered by Segment

GitHub

Stars40
Watchers2
Forks2
Issues0
Contributors1
Pull Requests0

Code

Files2
SizeIntegration Size 24 kb
LOCLines of Code 252


Sniffer 1.0.5

  • By
  • Kofktu

Sniffer

  • 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 3.0

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 = { [unowned self] (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.