Does the popular open-source framework AFNetworking have a mechanism for logging requests/responses to console?

StackOverflow https://stackoverflow.com/questions/8977641

  •  12-11-2019
  •  | 
  •  

Frage

I'd like to pump out the raw-ish HTTP requests/responses to the console to aid debugging.

I've looked at the various docs on GitHub and had a quick search through the code and couldn't find anything obvious, so I'm guessing the answer is no. But just wanted to check if I have missed anything obvious.

War es hilfreich?

Lösung

AFURLConnectionOperation sends notifications when operations start and end. You can easily log requests by listening for those notifications and logging the notification object:

[[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidStartNotification
                                                  object:nil
                                                   queue:nil
                                              usingBlock:^(NSNotification *note) {
                                                NSLog(@"Operation Started: %@", [note object]);
                                              }];

Combine with FormatterKit's TTTURLRequestFormatter for best results!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top