konkab / alamofirenetworkactivitylogger Goto Github PK
View Code? Open in Web Editor NEWNetwork request logger for Alamofire
License: MIT License
Network request logger for Alamofire
License: MIT License
Excellent framework.
I'm using .off
level, like this
NetworkActivityLogger.shared.level = .off
NetworkActivityLogger.shared.startLogging()
I see separators printed to the log whenever there is a network request, like this:
---------------------
---------------------
13:43:12.381 ☮️ VERBOSE SomeClass.func():27 - Saving stuff: 0x2D2CBCFF201865FF
---------------------
---------------------
---------------------
---------------------
13:43:12.500 ⛔️ ERROR AnotherClass.init():124 - jsonString cannot parse field x
13:43:12.502 ⛔️ ERROR AnotherClass.init():124 - jsonString cannot parse field y
13:43:12.502 ⛔️ ERROR AnotherClass.init():124 - jsonString cannot parse field z
13:43:12.503 ℹ️ INFO SomeViewController.loginSuccess():287 - Oauth token
---------------------
---------------------
Sometimes I’m getting crash in the networkRequestDidComplete method, screenshot and backtrace attached. Would you advice me what can be the reason?
* thread #50, queue = 'NSOperationQueue 0x17483d7a0 :: NSOperation 0x171c5b930 (QOS: DEFAULT)', stop reason = EXC_BAD_ACCESS (code=1, address=0xd2800014b40000f8)
frame #0: 0x000000018896815c libobjc.A.dylib`objc_msgSend + 28
frame #1: 0x00000001062fe3f8 libswiftCore.dylib`swift::metadataimpl::ValueWitnesses<swift::metadataimpl::ObjCRetainableBox>::initializeWithCopy(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*) + 24
frame #2: 0x0000000106193650 libswiftCore.dylib`Swift._VariantDictionaryBuffer.nativeDelete (Swift._NativeDictionaryBuffer<A, B>, idealBucket : Swift.Int, offset : Swift.Int) -> () + 828
frame #3: 0x0000000106193b90 libswiftCore.dylib`Swift._VariantDictionaryBuffer.nativeRemoveObject (forKey : A) -> Swift.Optional<B> + 872
frame #4: 0x00000001061807b4 libswiftCore.dylib`Swift._VariantDictionaryBuffer.removeValue (forKey : A) -> Swift.Optional<B> + 148
frame #5: 0x000000010615ccb8 libswiftCore.dylib`Swift.Dictionary.subscript.setter : (A) -> Swift.Optional<B> + 352
* frame #6: 0x0000000102de4c9c AlamofireNetworkActivityLogger`NetworkActivityLogger.networkRequestDidComplete(notification=Foundation.Notification @ 0x000000016ef15a80, self=0x000000017025fd70) -> () at NetworkActivityLogger.swift:162
frame #7: 0x0000000102de6294 AlamofireNetworkActivityLogger`@objc NetworkActivityLogger.networkRequestDidComplete(notification : Notification) -> () at NetworkActivityLogger.swift:0
frame #8: 0x0000000189e8d5f4 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
frame #9: 0x0000000189e8cd08 CoreFoundation`_CFXRegistrationPost + 400
frame #10: 0x0000000189e8ca84 CoreFoundation`___CFXNotificationPost_block_invoke + 60
frame #11: 0x0000000189efb7a8 CoreFoundation`-[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1412
frame #12: 0x0000000189dd095c CoreFoundation`_CFXNotificationPost + 376
frame #13: 0x000000018a8e2930 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 68
frame #14: 0x0000000102bc557c Alamofire`SessionDelegate.(session=0x00000001743cde30, task=0x000000011c6137a0, error=nil, self=0x0000000110a41810) -> ()).(closure #1) at SessionDelegate.swift:449
frame #15: 0x0000000102bc50a0 Alamofire`SessionDelegate.urlSession(session=0x00000001743cde30, task=0x000000011c6137a0, error=nil, self=0x0000000110a41810) -> () at SessionDelegate.swift:489
frame #16: 0x0000000102bc5fdc Alamofire`@objc SessionDelegate.urlSession(URLSession, task : URLSessionTask, didCompleteWithError : Error?) -> () at SessionDelegate.swift:0
frame #17: 0x000000018a6caad4 CFNetwork`__51-[NSURLSession delegate_task:didCompleteWithError:]_block_invoke.185 + 72
frame #18: 0x000000018a9c1814 Foundation`__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
frame #19: 0x000000018a906770 Foundation`-[NSBlockOperation main] + 96
frame #20: 0x000000018a8f6b28 Foundation`-[__NSOperationInternal _start:] + 612
frame #21: 0x000000018a9c3bb0 Foundation`__NSOQSchedule_f + 228
frame #22: 0x0000000106a29a10 libdispatch.dylib`_dispatch_client_callout + 16
frame #23: 0x0000000106a372e8 libdispatch.dylib`_dispatch_queue_serial_drain + 1140
frame #24: 0x0000000106a2d634 libdispatch.dylib`_dispatch_queue_invoke + 852
frame #25: 0x0000000106a39630 libdispatch.dylib`_dispatch_root_queue_drain + 552
frame #26: 0x0000000106a3939c libdispatch.dylib`_dispatch_worker_thread3 + 140
frame #27: 0x0000000188fb3100 libsystem_pthread.dylib`_pthread_wqthread + 1096
frame #28: 0x0000000188fb2cac libsystem_pthread.dylib`start_wqthread + 4
Details:
AlamofireNetworkActivityLogger v2.2
iOS 10.3.2,
Xcode 8.3.2
Swift 3.1
Thanks.
Are there any way to print response of the request?
macOS 10.13.4, Xcode 9.4 beta (9Q1004a).
Typed the prescribed text into Podfile and ran the install in the terminal successfully, but this error shows-up and I'm unable to use the tool
At the moment, filterPredicate
applies to both request and response.
There is, however, the case where we want to keep the log for a request, and doesn't care about its response.
It would be great to be able to install this using Xcode 11's SPM.
While runing
carthage update AlamofireNetworkActivityLogger
I'm getting
*** Skipped building AlamofireNetworkActivityLogger due to the error: Dependency "AlamofireNetworkActivityLogger" has no shared framework schemes
any ideas?
How can I listing all request and response logs?
I need listing in a tableview an open on development target for testers.
Found out some random crashes.
I'm not able to produce this every time, but it happens on real devices iPhone 11(iOS 14.2), iPhone X (iOS 14.6) as well as in simulators.
Here are some crashlogs from firebase crashlytics.
Crashed: com.apple.NSURLSession-delegate
0 libswiftCore.dylib 0x1a2fc39a4 swift_isUniquelyReferenced_nonNull_native + 34
1 AlamofireNetworkActivityLogger 0x10190f838 $s30AlamofireNetworkActivityLogger0bcD0C25networkRequestDidComplete33_C4DAE19DB50F7F6C893FBE4CEB3851D9LL12notificationy10Foundation12NotificationV_tF + 1864
2 AlamofireNetworkActivityLogger 0x10191072c $s30AlamofireNetworkActivityLogger0bcD0C22networkRequestDidStart33_C4DAE19DB50F7F6C893FBE4CEB3851D9LL12notificationy10Foundation12NotificationV_tFToTm + 120
3 CoreFoundation 0x19f298e8c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
4 CoreFoundation 0x19f298e4c ___CFXRegistrationPost_block_invoke + 48
5 CoreFoundation 0x19f298438 _CFXRegistrationPost + 400
6 CoreFoundation 0x19f297e30 _CFXNotificationPost + 696
7 Foundation 0x1a050a934 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
8 Alamofire 0x101808708 $s9Alamofire15SessionDelegateC03urlB0_4task20didCompleteWithErrorySo12NSURLSessionC_So0J4TaskCs0I0_pSgtFyAH_AjLtcfU_ + 964
9 Alamofire 0x101808300 $s9Alamofire15SessionDelegateC03urlB0_4task20didCompleteWithErrorySo12NSURLSessionC_So0J4TaskCs0I0_pSgtF + 868
10 Alamofire 0x1018093f0 $s9Alamofire15SessionDelegateC03urlB0_4task20didCompleteWithErrorySo12NSURLSessionC_So0J4TaskCs0I0_pSgtFTo + 108
11 CFNetwork 0x19fadd4c8 _CFNetworkHTTPConnectionCacheSetLimit + 153352
12 libdispatch.dylib 0x19ef6e2b0 _dispatch_call_block_and_release + 24
13 libdispatch.dylib 0x19ef6f298 _dispatch_client_callout + 16
14 libdispatch.dylib 0x19ef4b344 _dispatch_lane_serial_drain$VARIANT$armv81 + 568
15 libdispatch.dylib 0x19ef4be60 _dispatch_lane_invoke$VARIANT$armv81 + 452
16 libdispatch.dylib 0x19ef5566c _dispatch_workloop_worker_thread + 692
17 libsystem_pthread.dylib 0x1e76f55bc _pthread_wqthread + 272
18 libsystem_pthread.dylib 0x1e76f886c start_wqthread + 8
First of all, thank you for making this awesome library.
Is it possible to change min target to iOS 8.0 instead of iOS 9.0 ?
Thank you
Hi
Is there any property or something to enable beautify from the logs? I mean, I want to be able to setup the library to print
{ "name": "asd" }
or
{
"name": "asd"
}
This will be useful when your app have a lot of requests and having them big makes it hard to see them all.
Couldn't compile in Xcode 10.2 (Swift 5) due to version incompatibility
-> Related (Alamofire resolution): Alamofire/Alamofire#2761
Hi - I don't know exactly what the problem is here but I wanted to mention a hang I was experiencing and how I fixed it.
I was enabling logging in didFinishLaunchingWithOptions
and experiencing a hang only when launching on a real device, and only when not in a debugger.
Attaching Xcode to the hung app would wake the app up. Strange. Figured it might be threading related. A number of network requests fire at startup so there's a fair bit of activity on a variety of threads coming in to the logger.
I put the entire body of networkRequestDidStart
and networkRequestDidComplete
inside an OperationQueue.main.addOperation
. The hangs stopped when I did this.
This is probably not be the best solution, but I didn't get far enough to determine which code was causing the hang.
Is it possible that this doesn't work with Alamofire 4.8.2 because I don't see any logs?
Please help updating pod spec file to use Alamofire 5.0. Thank you!
Showing All Messages
: https://github.com/konkab/AlamofireNetworkActivityLogger.git has no Package.swift manifest for version 3.0.0
Please give SPM Support
• Beschreibung:
Für die bisherige Fehleranalyse wurde prototypisch eine Logfunktionalität eingebaut. Diese soll für die Zukunft beibehalten und fest in die App integriert werden. Diese soll wie bisher auch die Videofunktion über das Toggle-Menü aktivierbar sein.
• Erwartetes Ergebnis:
Dauerhafte Implementierung der Logfunktion. Aufruf über das Toggle-Menü. Exportmöglichkeit des gesamten Logs in eine TXT-Datei. Ergänzung um wichtige Informationen zum Betriebssystem wie Version, Modellbezeichnung, App-Version, ...
I am getting error following error in Xcode 8.2
'data' is inaccessible due to 'internal' protection level
Is there any fix for this?
Hello,
Is there any way to enable Separator for every new request?
Best Regards,
Sagar
This pod locks the Alamofire version to 5.4.0, but seems to work correctly when copied into our project directly. Could the podspec be updated to support the latest versions of Alamofire?
Hello.
Is this going to be supported anytime soon?
Thanks,
Dan.
Alamofire.upload(data, with: request)
.responseJSON(queue: dispatchQueue(), options: .allowFragments) { response in
in this case if data is Json encode data
let data = try! JSONEncoder().encode(redirectRequest)
can we log it with ?
Hello, in Xcode 15, OSLog is fully integrated into the console of Xcode, and allow to filter, display som informations about the log.
Currently this repo uses the Swift print method. is there a plan on updating to OSLog ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.