Closed myrne closed 10 years ago
console.log should go to the Console already.
Still it can be reasonable request. I use remote_js and it implements console.log, that way I would have both options available at same time. In 4 opened pull-requests like 3 of them have their .log function :) so it looks like thing many people want.
Just wondering, does this log JavaScript objects in a readable way?
I don't see this doing anything more than what's already in MacGap (see code below), but please reopen if I've missed it!
- (void) webView:(WebView*)webView addMessageToConsole:(NSDictionary*)message
{
if (![message isKindOfClass:[NSDictionary class]]) {
return;
}
NSLog(@"JavaScript console: %@:%@: %@",
[[message objectForKey:@"sourceURL"] lastPathComponent], // could be nil
[message objectForKey:@"lineNumber"],
[message objectForKey:@"message"]);
}
I couldn't find an obvious way to access what's gets written to console.log, so I added this helper function.