From 908e5d2659acddc81afdd9d265ad414a4098317f Mon Sep 17 00:00:00 2001 From: Armando Sosa Date: Mon, 9 Sep 2013 21:55:02 -0500 Subject: [PATCH] Fixes https://github.com/LearnBoost/console-trace/issues/14 Without breaking backwards compatibility --- console-trace.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console-trace.js b/console-trace.js index 126bcaf..e8aa13d 100644 --- a/console-trace.js +++ b/console-trace.js @@ -1,4 +1,3 @@ - /** * Module dependencies. */ @@ -40,7 +39,8 @@ module.exports = function (options) { arguments[0] = JSON.stringify(arguments[0], null, ' '); } var pad = (arguments[0] && !console.traceOptions.right || !isatty ? ' ' : ''); - arguments[0] = console.traceFormat(__stack[1], name) + pad + arguments[0]; + var stack = (typeof __stack !== 'undefined') ? __stack : callsite(); + arguments[0] = console.traceFormat(stack[1], name) + pad + arguments[0]; } console._trace = false; return fn.apply(this, arguments);