1
0
Fork 0

added trace

This commit is contained in:
Frank Celler 2013-04-03 16:32:04 +02:00
parent e68080a638
commit 0ba6329a12
2 changed files with 28 additions and 15 deletions

View File

@ -289,23 +289,15 @@
/// log message.
////////////////////////////////////////////////////////////////////////////////
exports.log = function () {
'use strict';
var msg;
try {
msg = sprintf.apply(sprintf, arguments);
}
catch (err) {
msg = err + ": " + arguments;
}
log("info", msg);
};
exports.log = exports.info;
////////////////////////////////////////////////////////////////////////////////
/// @brief time
///
/// @FUN{console.time(@FA{name})}
///
/// Creates a new timer under the given name. Call @FN{timeEnd} with the same
/// name to stop the timer and log the time elapsed.
////////////////////////////////////////////////////////////////////////////////
exports.time = function (label) {
@ -316,6 +308,10 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief timeEnd
///
/// @FUN{console.timeEnd(@FA{name})}
///
/// Stops a timer created by a call to @FN{time} and logs the time elapsed.
////////////////////////////////////////////////////////////////////////////////
exports.timeEnd = function(label) {
@ -333,6 +329,23 @@
exports.log('%s: %dms', label, duration);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief trace
///
/// @FUN{console.trace()}
///
/// Logs a static stack trace of JavaScript execution at the point where it is
/// called.
////////////////////////////////////////////////////////////////////////////////
exports.trace = function () {
var err = new Error();
err.name = 'trace';
err.message = sprintf.apply(sprintf, arguments);
Error.captureStackTrace(err, arguments.callee);
exports.log(err.stack);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief warn
///

View File

@ -696,7 +696,7 @@ static v8::Handle<v8::Value> JS_SizeFile (v8::Arguments const& argv) {
///
/// @FUN{console.getline()}
///
/// Reads in a line from the console.
/// Reads in a line from the console and returns it as string.
////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> JS_Getline (v8::Arguments const& argv) {