0

I'm not sure, if this is really a question or more an observation - or even a bug.

Throughout my javascript code I'm using many console.log and console.group statements to track whats happening internally. The code also does some recursion, thus making it quite important to have the indentation of the groups correct.

//working dummy code illustrating the problem
var data=3;
var demo=(function(){
    var internal=function(){
        console.group("internal");
        console.log("some smart shit");
        console.groupEnd();
    }

    console.group("inside the closure1");
    console.group("inside the closure2");

    internal();

    if (data===5){
        console.log("funny Things");
    }

    console.groupEnd();
    console.log("some smart shit 1");
    console.groupEnd();

}( data ));
console.log("Indentation correct?!");

If all code blocks are executed, the tree built in the console goes deep, but bubbles back up to the root level of the hierarchy. Now, if a block doesn't execute an other block and nothing is logged to the console, the indentation remains at +1 after leaving the code block.

Change the

var data=5
in the obove dummy code to
var data=3
and you'll see that the indentation will be wrong!

More generally speaking; Nesting console.group's without using a console.log for every time console.group was called results in false indentation!

I know, that the ChromeDevTeam have referred to the firebug console api while implementing the chromedevtools and assume this behavior is the same in firebug.

I now question if anybody has experienced the same behavior? Does anybody know if this behavior is as expected? And most importantly; does anyone know a workaround to fix this indentation problem? Of course, I could console.log something every time I open up a group, but this isn't really the idea, if you ask me..

Thanks for any helpful information on this topic and sorry, if this question is kinda lame :(

//Edit Nr2 -> I've updated the code to illustrate the problem. It now generates the false indentation as described (against what I am expecting).

2
  • I think you'd be more likely to get answers on this if you posted sample code with expected/actual output - otherwise it's a bit hard to follow the problem/situation you're trying to explain. Jun 22, 2011 at 3:29
  • I added working sample code illustrating the problem and how to reconstruct the problem. Thanks for the hint :)
    – japrescott
    Jun 27, 2011 at 13:31

1 Answer 1

1

I filed a bug on this issue: https://bugs.webkit.org/show_bug.cgi?id=63455

1
  • thank you for filing the bug! (have never thought I would ever find a bug in a 'product' such as webkit! Yay, I'm soooo cool ;) )
    – japrescott
    Jun 27, 2011 at 23:44

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.