Skip to content

Instantly share code, notes, and snippets.

@kirkouimet
Last active October 30, 2017 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirkouimet/1e3dea6b5ead49e282c5b6949324e8f8 to your computer and use it in GitHub Desktop.
Save kirkouimet/1e3dea6b5ead49e282c5b6949324e8f8 to your computer and use it in GitHub Desktop.
We need a way to wrap console.log and preserve the file and line number
<html>
<head>
<title>We need a way to wrap console.log and preserve the file and line number</title>
<script>
function customLog() {
var processedArguments = arguments;
// Do something with the arguments besides logging them, maybe format them or store them
// ...
// Send the output to Developer Tools
// The expectation here is that we can call console.log in a different way such that the
// Developer Tools should not show this next line as the originating line in the console
console.log(arguments); // Just call it in the classic way since there is no special way to call it yet
}
</script>
</head>
<body>
<p><a target="_blank" href="https://bugs.chromium.org/p/chromium/issues/detail?id=779244#c1">We need a way to wrap console.log and preserve the file and line number.</a></p>
<button onclick="customLog('Should show line number 19.')">Developer Tools should show a log entry originating from line 19.</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment