Install AlamofireNetworkActivityLogger via Carthage
masterTo integrate AlamofireNetworkActivityLogger using Carthage, add the following line to your Cartfile:
github "konkab/AlamofireNetworkActivityLogger" ~> 3.4repository·master·Indexed 42 days ago
https://github.com/konkab/alamofirenetworkactivityloggerA utility for Alamofire that automatically logs network request and response details, including URL, method, status code, and duration, to the console. Supports integration via CocoaPods, Carthage, and Swift Package Manager.
To integrate AlamofireNetworkActivityLogger using Carthage, add the following line to your Cartfile:
github "konkab/AlamofireNetworkActivityLogger" ~> 3.4To add AlamofireNetworkActivityLogger as a dependency in your Package.swift file, add it to the dependencies array:
dependencies: [
.package(url: "https://github.com/konkab/AlamofireNetworkActivityLogger.git", .upToNextMajor(from: "3.4.0"))
]To integrate AlamofireNetworkActivityLogger using CocoaPods, ensure you have CocoaPods 1.10.0+ installed. Add the following to your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
pod 'AlamofireNetworkActivityLogger', '~> 3.4'Then, run pod install in your terminal.
To start logging all NSURLSessionTask objects created by an Alamofire.Session, import the library and call startLogging() on the shared instance within your AppDelegate.
All requests and responses will be printed to the console in a formatted block showing the HTTP method, URL, status code, and duration.
import AlamofireNetworkActivityLogger
// In AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
NetworkActivityLogger.shared.startLogging()
return true
}You can adjust the verbosity of the logs by setting the level property on the NetworkActivityLogger.shared instance. For example, to only log errors, set the level to .error.
NetworkActivityLogger.shared.level = .error