If anyone is interested, I've started on a JavaScript tracing library called Autolog.js that sends "cleaned"/formatted Function.prototype.call executions to console.log (tested/works in Chrome 29):
https://github.com/garysweaver/autolog.jse.g. some sample output from loading an Angular.js app:
[object NamedNodeMap].toString () source: at isArrayLike (
http://example.org/assets/angular.js?body=1:39:83)
undefined.anonymous ((object)[object Attr], (number)0) source: at forEach (
http://example.org/assets/angular.js?body=1:55:20)
undefined.anonymous ((object)$compile,$parse,function ($compile, $parse) {...}, (string)"select") source: at forEach (
http://example.org/assets/angular.js?body=1:59:22)
So, it works, but some help via PR's would be great. For example, could use some help getting it cleaned up and working with npm/node, bower, etc. and maybe to have a more flexible formatting mechanism, datetime-stamping, etc.
The original functionality was based on this answer from HBP on StackOverflow:
http://stackoverflow.com/a/5244434/178651 but I was interested in logging via console.log, not logging full function bodies which get messy, and I wanted to show line#s via doing a throw/catch to capture, which I've tried to minimize dependence by just allowing on stacktrace.js by doing some messy stuff like:
...
var gotSource = false,
cleanStack = '',
stack = '' + (ex.stack || ex.stacktrace || ex.message || '');
stack = stack.split('\n');
for (var i = 0, len = stack.length; i < len; i++) {
if (stack[i].indexOf('autolog.js') == -1 && (stack[i].indexOf('ine ') > -1 || stack[i].indexOf('unction') > -1 || stack[i].indexOf('at ') > -1 || stack[i].indexOf('eval ') > -1 || (stack[i].indexOf('@') > -1 && stack[i].indexOf(':') > -1))) {
if (Autolog.getIncludeCallerLocation() && !gotSource) {
line += ' source: ' + stack[i].trim();
gotSource = true;
}
...
It probably has a slew of problems that need addressing (not tested in strict mode to see whether message works, not tested in other browsers, not sure how helpful it is in other environments, etc.), but I wanted a tracing tool like the wrapper like the one I wrote in Ruby
https://github.com/garysweaver/autolog that just wraps set_trace_func. The js version is not as full-featured obviously, but it works ok.
Thanks for checking it out,
Gary