
module.exports = function(flowData){
  var logDeep = 0;
  var logBuffer = [];

  var slice = Array.prototype.slice;
  var push = Array.prototype.push;

  flowData.console = {
    log: function(){
      var args = slice.call(arguments);
      args.unshift(new Array(logDeep).join('  '));

      if (logBuffer.length)
        logBuffer[logBuffer.length - 1].push(args);
      else
        console.log.apply(console, args);
    },
    incDeep: function(){
      //console.log('deep++');
      logDeep++;
    },
    decDeep: function(){
      //console.log('deep--');
      logDeep--;
    },
    push: function(){
      logBuffer.push([]);
    },
    pop: function(){
      return logBuffer.pop();
    },
    flush: function(messages){
      if (logBuffer.length)
        push.apply(logBuffer[logBuffer.length - 1], messages);
      else
        messages.forEach(function(args){
          console.log.apply(console, args);
        });
    },
    flushAll: function(){
      while (logBuffer.length)
        this.flush(this.pop());

      logDeep = 0;
    }
  };
}
@@ -237,24 +237,48 @@
 rguments);%0D%0A
+%0D%0A      if (logDeep)%0D%0A  
       args.u
@@ -301,16 +301,20 @@
 (logDeep
+ + 1
 ).join('
@@ -317,16 +317,26 @@
 in('  ')
+.substr(1)
 );%0D%0A%0D%0A  
@@ -508,40 +508,8 @@
 )%7B%0D%0A
-      //console.log('deep++');%0D%0A
     
@@ -566,34 +566,82 @@
     
-//console.log('d
+if (logDeep %3E 0)%0D%0A        logD
 eep--
-')
 ;%0D%0A
+    %7D,%0D%0A    resetDeep: function()%7B%0D%0A
     
@@ -641,34 +641,36 @@
 %7B%0D%0A      logDeep
---
+ = 0
 ;%0D%0A    %7D,%0D%0A    p

fix console deep output