Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » console.log() replacement issues

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

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

Page: 1
Go to End
Author Topic: 1758 Views
  • Sam
    Avatar
    Administrator
    679 Posts

    console.log() replacement issues Link to this post

    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?

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: console.log() replacement issues Link to this post

    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.

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: console.log() replacement issues Link to this post

    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

    1758 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.