1.1 --- a/embeddedconsole.user.js Tue Nov 25 14:20:18 2008 +0000
1.2 +++ b/embeddedconsole.user.js Tue Nov 25 14:25:44 2008 +0000
1.3 @@ -218,29 +218,53 @@
1.4 Console.prototype.trace = function (key, scope) {
1.5 var thisConsole = this;
1.6 var originalFunction;
1.7 + var traceRecord;
1.8
1.9 if (scope == null) {
1.10 scope = unsafeWindow;
1.11 }
1.12
1.13 originalFunction = scope[key];
1.14 - this.traces.push({scope: scope, key: key, originalFunction: originalFunction});
1.15 + traceRecord = {scope: scope,
1.16 + key: key,
1.17 + originalFunction: originalFunction,
1.18 + lastInput: undefined,
1.19 + lastOutput: undefined,
1.20 + lastError: undefined};
1.21 + this.traces.push(traceRecord);
1.22 scope[key] = function () {
1.23 var args = [];
1.24 for (var i = 0; i < arguments.length; i++) { args.push(arguments[i]); }
1.25 thisConsole.inspectOutput(key + ": INPUT", args);
1.26 + traceRecord.lastInput = args;
1.27 var result;
1.28 try {
1.29 result = originalFunction.apply(this, arguments);
1.30 } catch (e) {
1.31 thisConsole.recordError(key + ": ERROR", e);
1.32 + traceRecord.lastError = e;
1.33 throw e;
1.34 }
1.35 thisConsole.inspectOutput(key + ": OUTPUT", result);
1.36 + traceRecord.lastOutput = result;
1.37 return result;
1.38 };
1.39 }
1.40
1.41 +Console.prototype.traceRecord = function (key, scope) {
1.42 + if (scope == null) {
1.43 + scope = unsafeWindow;
1.44 + }
1.45 +
1.46 + for (var i = 0; i < this.traces.length; i++) {
1.47 + var entry = this.traces[i];
1.48 + if (entry.scope === scope && entry.key === key) {
1.49 + return entry;
1.50 + }
1.51 + }
1.52 + return null;
1.53 +}
1.54 +
1.55 Console.prototype.untrace = function (key, scope) {
1.56 if (scope == null) {
1.57 scope = unsafeWindow;