openexchangerates / javascript-sandbox-console

a mini interactive javascript console for library/plugin demos and homepages
http://openexchangerates.github.io/javascript-sandbox-console/
MIT License
319 stars 58 forks source link

console.log command missing #18

Open marco-faustinelli opened 9 years ago

marco-faustinelli commented 9 years ago

There should be a way to print stuff on the sandbox screen. I understand that console.log belongs to the browser console, but something like sandbox.log should be available.

DanWilkerson commented 7 years ago

It's a hack, but if you're using an iframe, you can do this:

  window.sandbox.model.sandbox.console = { 
    log: function(msg) {

      console.log(msg);
      return msg;

    }   
  }; 

[Edit:] The above fails when an async call is involved, unfortunately.. If I come up with a fix, I'll update here.