Voloda2
Voloda2

Reputation: 12617

Is it possible to read app specific warning messages?

I want to read the console of my application. My aim is find all messages like this:

Warning: Attempt to present <ChildViewController: 0x7b44e380>  on <TopViewController: 0x7a65e5b0> which is already presenting (null)

I founded that on iOS7 you can’t read system messages.

Using Objective C to read log messages posted to the device console

In iOS 7 you can use ASL to read messages output by your own app, including on previous runs of the same build of your app, but not messages output by the system or by any other apps.

For my mind any warnings is a system messages. May be something changes on ios8?

Upvotes: 1

Views: 154

Answers (1)

Woodstock
Woodstock

Reputation: 22956

It's possible to read from the "syslog.sock". There is source on Github which works under iOS8: https://github.com/eswick/ondeviceconsole

ASL no longer works from iOS7 onwards for system wide logs, iOS 7+ apps can only see their own log messages due to increased sandboxing.

If you only want to see your own app's logs, you can still use ASL:

 aslmsg q, m;
 int i;
 const char *key, *val;
 q = asl_new(ASL_TYPE_QUERY);
 aslresponse r = asl_search(NULL, q);
 while (NULL != (m = aslresponse_next(r)))
{
    NSMutableDictionary *tmpDict = [NSMutableDictionary dictionary];
    for (i = 0; (NULL != (key = asl_key(m, i))); i++)
    {
        NSString *keyString = [NSString stringWithUTF8String:(char *)key];
        val = asl_get(m, key);
        NSString *string = val?[NSString stringWithUTF8String:val]:@"";
        [tmpDict setObject:string forKey:keyString];
    }
    NSLog(@"%@", tmpDict);
}
aslresponse_free(r);

Upvotes: 1

Related Questions