Alamofire+Logging
为 Alamofire 提供日志支持
安装
CocoaPods
要使用 CocoaPods 安装 Alamofire+Logging,请在您的 Podfile
中添加以下行。
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'AlamofireLogging'
Carthage
Carthage 是一个去中心化的依赖项管理器,它会构建您的依赖项并提供二进制框架。
您可以使用以下命令使用 Homebrew 安装 Carthage
$ brew update
$ brew install carthage
要在您的 Xcode 项目中集成 Alamofire+Logging 使用 Carthage,在您的 Cartfile
中指定它
github 'Digipolitan/alamofire-logging' ~> 1.0
运行 carthage update
来构建框架,并将构建出的 AlamofireLogging.framework
拖到您的 Xcode 项目中。
Swift 包管理器
Swift 包管理器(Swift Package Manager)是一个自动化分发 Swift 代码的工具,并集成到Swift编译器中。
设置好您的 Swift 包后,可以将 Alamofire+Logging 添加为依赖项,就像在您的 Package.swift
中的 dependencies
值中添加它一样简单。
dependencies: [
.package(url: "https://github.com/Digipolitan/alamofire-logging.git", from: "1.0.0")
]
如何使用?
SessionManager.default.request("http://date.jsontest.com").log(level: .verbose).responseJSON { (response) in
switch response.result {
case .success(let value):
print("Alamofire \(value)")
case .failure(let error):
print("\(error)")
}
}
日志有多个级别
- 无:不显示任何日志
- 简单:仅记录 URL
- 详细:记录 HTTP 请求的所有内容,如头信息、正文、查询等
贡献
有关详细信息,请参阅CONTRIBUTING.md!
此项目遵循贡献者公约行为准则。您参与时,应遵守本准则。如有不适当的行为,请向以下邮箱[email protected]报告。
许可
Alamofire+Logging 使用的是BSD 3-Clause 许可证。