Because I'm lazy, I created a function log
that basically is just an abbreviation of console.log
:
function log() { console.log.apply(console, arguments); }
Whenever I call this, I see the logged item in Google Chrome's Developer Tools, with on the right hand side the line number where the item was logged. However, this line number is always the same, because the actual console.log
call is located at one specific place in the code (namely where I declare the log
function as above).
What I also tried is just:
var log = console.log;
but this always throws an error: Illegal invocation
. Weird, but I guess that's not a possibility.
How can I make a shortcut to console.log
, with Developer Tools showing the line number where log
was called, rather than where the actual console.log
call is located?
To open the developer console in Google Chrome, open the Chrome Menu in the upper-right-hand corner of the browser window and select More Tools > Developer Tools. You can also use Option + ⌘ + J (on macOS), or Shift + CTRL + J (on Windows/Linux).
Adding a console log is something Google recently add. In the selected row instead of left click,click right click and select 'add logpoint', a small text box will pop up, enter the variable you want you console log. If you do not see this feature update your browser. Thanks for the answer!
To add shortcut links to the sites on the Home screen with Chrome Android, firstly launch the site whose link you wish to add to the Home screen. Now, tap on the three dots>Add to home screen>Add. This will automatically add the shortcut link to the home screen of your Android phone.
When I reported it, it was refused but the answer was simple - create the shortcut like this:
var log = console.log.bind(console);
This doesn't leave out the line number, whilst you can call it like log(...)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With