Question

I use Firefox + Firebug for some Javascripting. The text I'm trying to log with console.log does not immediately appear in Firebug's console. It seems like it piles up in a buffer somewhere, and then gets flushed to console in chunks. I have a function that makes a few log calls. Sometimes I get just the first line, sometimes - nothing. I do, however, see the whole bunch of lines when I refresh the page.

Can I flush the console log manually?

Was it helpful?

Solution

The short answer is no. There is no flush. You could clear the console

console.clear();

But I don't think that's what you want. This is most likely from the code. If we can see it, I can revise my answer with better feedback.

If you want to see all the available methods under console, execute this in the command line:

for(var i in console) {
    console.log(i);
}

or have a look at the wiki page of the console API.

OTHER TIPS

It's not a Firefox problem, It's a JavaScript problem because execution is delayed and variables are updated so you can see only the last value.

To see immediately the output you need to convert your object in string so it will not change also if object will be updated.

I wrote this easy function :

function printLog(s) {
   if (typeof(s) === 'object') {
      console.log( JSON.stringify(s) );
   } else {
      console.log(s);
   }
}

The printed output is a string (so you can't interact with it) but it contains the real dynamic object that you want to see at the print time instant.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top