Domanda

I'm debugging a 3rd party SDK which puts lot of useful information into the console.

I used to display some messages in tooltips (for our tester), which I'm receiving from SDK delegate.

But delegate methods don't include many details and sometimes it turns helpless, otherwise console includes much more helpful information (especially if the SDK's log level is set to DEBUG_ALL or something like that).

So, my question - is it possible to observe NSLog messages and to be notified in some way when they are printed to console? Of course I would like to have string message as a parameter?

I would like to display it on device/simulator screen, so that the tester doesn't have to run XCode or view the device's console.

È stato utile?

Soluzione

I'm using iConsole for the same purpose. It's quite useful.

Altri suggerimenti

What SDK? If the SDK supports CocoaLumberjack, then I suggest installing that, and configuring the loggers to do what you want -- even route somewhere else.

CocoaLumberjack gives you a lot of power and configurability when it comes to logging.

If your SDK uses NSLog to print the details in the console, then you can use macros to redefine the NSLog.

    #define NSLog(FORMAT, ...) ShowLogInAlert(FORMAT);


   void ShowLogInAlert(NSString *format, ...){
    //show the log in the alert here.

    va_list ap;
    va_start (ap, format);
    format = [format stringByAppendingString:@"\n"];
    NSString *msg = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%@",format] arguments:ap];
//    NSLog(@"%@", msg);
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:msg message:@"" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert show];
    va_end (ap);

}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top