reading the firebug console in javascript

后端 未结 5 584
春和景丽
春和景丽 2020-12-19 16:37

I\'m looking for a way to read the most recent command that was logged to the firebug console.

For example, I could have something that does

console.         


        
5条回答
  •  甜味超标
    2020-12-19 17:31

    You might wanna implement a queue. Expanding on Devin's answer: (something like this)

    var window.log = [];
    
    logger function(msg) {
      var log_length = 10;
      console.log(msg);
      window.log.push(msg);
      if(window.log.length > log_length) {
        window.log.shift()
      }
    }
    

    See:
    How do you implement a Stack and a Queue in JavaScript?
    http://aymanh.com/9-javascript-tips-you-may-not-know#string-concatenation-vs-arrayjoin

提交回复
热议问题