How can I log each request/response using Alamofire?

前端 未结 8 1401
迷失自我
迷失自我 2020-12-23 16:20

Is there a way to log each request / response using Alamofire (something similar to AFNetworkActivityLogger) ?

I am aware of Printable, DebugPrintable and Output (cU

8条回答
  •  伪装坚强ぢ
    2020-12-23 16:25

    Timberjack is what you are looking. 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.

    https://cocoapods.org/pods/Timberjack

    usage:

    import Alamofire
    import Timberjack
    
    class HTTPManager: Alamofire.Manager {
    static let sharedManager: HTTPManager = {
        let configuration = Timberjack.defaultSessionConfiguration()
        let manager = HTTPManager(configuration: configuration)
        return manager
    }()
    }
    

提交回复
热议问题