Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

console.log() replacement issues


Reply

3 Posts   1828 Views

Avatar
Sam

13 June 2007 at 11:18am Administrator, 685 Posts

There appears to be code in protoype_improvements.js that provides a replacement console.log() in cases where you don't have firebug installed.

The problem is that this has a habit of popping up on production sites.

Who wrote this code? What's the best way of fixing this? Do we need a reliable way of calling Director::isDev() from within javascript, perhaps?

Avatar
Ingo

13 June 2007 at 1:38pm Forum Moderator, 801 Posts

i've implemented the firebug-replacement.
you can use Debug.isTest() in javascript to limit console.log()-calls to non-live environments (has the same restrictions as Director::isLive(), just regexing the url for ".test" and ".dev"). you can override this behaviour with Debug.set_environment_type(). see http://doc.silverstripe.com/doku.php?id=debug

then again, console.log()-code should not be committed at all - it produces a javascript-error if the firebug-replacement is not existing.

Avatar
Sam

13 June 2007 at 2:39pm Administrator, 685 Posts

Alright, I've stitched these two up. If you're on a live site, then the console.log messages will be silently dropped.

I also fixed Debug.isLive() - it now calls !Debug.isDev()

Although you're right about getting rid of console.log messages after you've finished debugging, this will prevent ones that slip through from breaking sites.

Changeset here: http://trac.silverstripe.com/projects/gsoc/changeset/36771