Возможно кому то пригодится, допилил функцию представленную выше:
function print_r(arr, level) {
var print_red_text = '';
var level_padding = '';
var dopPadding = ' ';
if(!level)
level = 0;
for(var j=0; j<level+1; j++) {
level_padding += " ";
}
if (level > 1) {
level_padding += dopPadding;
}
print_red_text = "Array \n" + (level > 0 ? level_padding + '' : '') + "(\n";
if(typeof(arr) == 'object') {
for(var item in arr) {
var value = arr[item];
if (typeof(value) == 'object') {
print_red_text += (level > 0 ? level_padding + '' : '') + " [" + item + "] => " + print_r(value, level+1) + "\n";
} else {
print_red_text += (level > 0 ? level_padding + '' : '') + " [" + item + "] => " + value + "\n";
}
}
}
else {
print_red_text = "===>"+arr+"<===("+typeof(arr)+")";
}
print_red_text += (level > 0 ? level_padding : '') + ")\n";
return print_red_text;
}