Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Credit to @Langdon for pointing me in the right direction.</p> <p><strong>[NOTE]</strong> this solution will only work in <strong><em>Chrome</em></strong>. For more info look at:</p> <ul> <li><a href="https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi" rel="nofollow">https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi</a></li> <li><a href="https://developers.google.com/chrome-developer-tools/docs/console" rel="nofollow">https://developers.google.com/chrome-developer-tools/docs/console</a></li> <li><a href="https://developers.google.com/chrome-developer-tools/docs/console-api" rel="nofollow">https://developers.google.com/chrome-developer-tools/docs/console-api</a></li> </ul> <p>Here is the workaround I implemented:</p> <pre class="lang-js prettyprint-override"><code>Object.defineProperty(window, '__stack', { get : function() { var orig = Error.prepareStackTrace; Error.prepareStackTrace = function(_, stack) { return stack; }; var err = new Error; Error.captureStackTrace(err, arguments.callee); var stack = err.stack; Error.prepareStackTrace = orig; return stack; } }); Logger.log = function(msg) { var stack = __stack; var link = stack[1].getFileName() + ':' + stack[1].getLineNumber(); console.groupCollapsed("%c" + msg, "font-weight: normal;"); $log.log(link); // or console.log(link) if you're not using angular. console.groupEnd(); }; </code></pre> <p><strong>[NOTE]</strong> In the chrome dev tools console I do not know how to overwrite the link that is given on the right. I have looked for documentation about that but I didn't find anything. Please let me if you know if you find out as this would look much neater.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload