MacGapProject / MacGap1

Desktop WebKit wrapper for HTML/CSS/JS applications.
Other
3.55k stars 209 forks source link

Allow logging with macgap.app.log #66

Closed myrne closed 10 years ago

myrne commented 11 years ago

I couldn't find an obvious way to access what's gets written to console.log, so I added this helper function.

maccman commented 11 years ago

console.log should go to the Console already.

JLarky commented 11 years ago

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.

jeff-h commented 10 years ago

Just wondering, does this log JavaScript objects in a readable way?

jeff-h commented 10 years ago

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"]);
}