diff --git a/src/deprecate-utils.coffee b/src/deprecate-utils.coffee index 4200b53b0..165209a0e 100644 --- a/src/deprecate-utils.coffee +++ b/src/deprecate-utils.coffee @@ -1,6 +1,16 @@ _ = require 'underscore' class DeprecateUtils + # See + # http://www.codeovertones.com/2011/08/how-to-print-stack-trace-anywhere-in.html + @parseStack: (stackString) -> + stack = stackString + .replace(/^[^\(]+?[\n$]/gm, '') + .replace(/^\s+at\s+/gm, '') + .replace(/^Object.\s*\(/gm, '{anonymous}()@') + .split('\n') + return stack + @warn: (condition, message) -> console.warn message if condition @@ -8,10 +18,11 @@ class DeprecateUtils if NylasEnv.inDevMode() and not NylasEnv.inSpecMode() warn = true newFn = => + stack = DeprecateUtils.parseStack((new Error()).stack) DeprecateUtils.warn( warn, "Deprecation warning! #{fnName} is deprecated and will be removed soon. - Use #{newName} instead." + Use #{newName} instead.\nCheck your code at #{stack[1]}" ) warn = false return fn.apply(ctx, arguments)