Verified Logging of duplicate messages results in fewer log events than it should. I used this script to verify. It tries the logging at 3 different times (before ready occurs, during the ready event, and after ready has finished) just to be certain it doesn't have to do with internals getting set up. var logSame = true;
log('begin pre-ready loop test');
var tst = [ 1, 2, 3, 4, 5, 6, 7 ,8];
_.each( tst, function ( item) {
if(logSame) {
log( "here");
} else {
log('item: '+item);
}
});
log('end pre-ready loop test');
on('ready',function(){
log('begin ready loop test')
_.each( tst, function ( item) {
if(logSame) {
log( "here");
} else {
log('item: '+item);
}
});
log('end ready loop test');
setTimeout(function(){
log('begin post-ready loop test')
_.each( tst, function ( item) {
if(logSame) {
log( "here");
} else {
log('item: '+item);
}
});
log('end post-ready loop test');
},1);
})
With logSame set to false, I get: "begin pre-ready loop test"
"item: 1"
"item: 2"
"item: 3"
"item: 4"
"item: 5"
"item: 6"
"item: 7"
"item: 8"
"end pre-ready loop test"
"begin ready loop test"
"item: 1"
"item: 2"
"item: 3"
"item: 4"
"item: 5"
"item: 6"
"item: 7"
"item: 8"
"end ready loop test"
"begin post-ready loop test"
"item: 1"
"item: 2"
"item: 3"
"item: 4"
"item: 5"
"item: 6"
"item: 7"
"item: 8"
"end post-ready loop test"
With logSame set to true, I get some variation on: "begin pre-ready loop test"
"here"
"here"
"here"
"end pre-ready loop test"
"begin ready loop test"
"here"
"here"
"here"
"here"
"end ready loop test"
"begin post-ready loop test"
"here"
"here"
"here"
"end post-ready loop test"
In the interim, you could write your own logging function that prefaces with at number to prevent the problem: var nlog=(function(l){ var reallog=l, cnt=0; return function(arg){ reallog( (_.contains(['string','number'],typeof arg) ? '<'+(++cnt)+'>: '+arg : arg ) ); }; }(log)); You could actually name that log and it would replace the built in log function.