Ox.trace: formatting; add documentation

This commit is contained in:
rolux 2015-04-24 13:51:04 +02:00
parent 6a5cb61880
commit eae9074cea

View file

@ -272,16 +272,22 @@ Ox.print = function() {
return args.join(' ');
};
/*@
Ox.trace <f> Prints its arguments to the console, followed by a stack trace
(arg, ...) -> <s> String
@*/
Ox.trace = function() {
var args = Ox.slice(arguments);
try {
throw new Error();
} catch (e) {
if (e.stack) {
args.push('\n' + e.stack.split('\n').slice(2).join('\n'));
args.push(
'\n' + Ox.clean(e.stack.split('\n').slice(2).join('\n'))
);
}
}
Ox.print.apply(null, args);
return Ox.print.apply(null, args);
};
/*@