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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

console.log() replacement issues


Go to End


3 Posts   2423 Views

Avatar
Sam

Administrator, 690 Posts

13 June 2007 at 11:18am

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

Forum Moderator, 801 Posts

13 June 2007 at 1:38pm

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

Administrator, 690 Posts

13 June 2007 at 2:39pm

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