AlamofireLogger 1.0.2

AlamofireLogger 1.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Nov 2020
SPMSupports SPM

Maintained by Daniel Clelland.



  • By
  • Daniel Clelland

AlamofireLogger

Tiny Alamofire plugin that logs requests and responses. Uses the Apple unified logging system to persist logs if necessary.

Cocoapods: pod 'AlamofireLogger', '~> 1.0'

✓ Simple installation

import AlamofireLogger

@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        NetworkActivityLogManager.shared.level = .simple
        return true
    }

}

✓ Custom formatters

NetworkActivityLogManager.shared.level = .custom(
    startFormatter: { request in
        return .debug("Request started: \(request.description)")
    },
    stopFormatter: { request in
        if let error = request.error {
            return .error("Request failed: \(error.localizedDescription)")
        } else {
            return .debug("Request completed: \(request.description)")
        }
    }
)