Chrome devtools: Using logpoints for logging messages directly

When it comes to debugging JavaScript in Chrome devtools, there are two different camps: the console.log fans and the debugger/breakpoint maximalist. I often switch between the two depending on what problem I am tackling. There is a third option that is kind of in the middle. Logpoints provide us with a breakpoint-like mechanism that logs variables instead of halting the execution.

How to add a logpoint

  1. Open devtools
  2. Right click the line at which you want to add the logpoint
  3. Provide the message as well as any variables that you want to be logged

All variables that are present in the current context can be logged using this.

- Advertisement -

Here’s a video for the steps:

This is particularly useful when dealing with third-party scripts which you cannot modify using your source code. Plus it saves a bunch of console.log/debugger cleanup once you are done debugging.

And that is it for this quick tutorial! Hope you found this tip useful and will start using more of it in your day-to-day debugging. Happy coding!

Recent Articles

Benefits Of Guest Blogging For SEO

Guest blogging entails the art of writing and publishing posts to be content for someone else. Guest blogging and posting on other...

Chrome devtools: Using logpoints for logging messages directly

When it comes to debugging JavaScript in Chrome devtools, there are two different camps: the console.log fans and the debugger/breakpoint maximalist. I...

How to prevent npm install for unsupported Node.js versions

npm configurations allow us to do quite a lot of nifty things. One of them is to allow the project to set...

How to terminate a process on a port using the command line

Zombie processes are usually a pain to figure out. More often than not, I end up googling about how to terminate a...

Detecting dark mode preference using JavaScript

As dark themes have become popular across the web and across operating systems, we might want to check the user's operating system...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Hi there! Want some more knowledge?

Think that the knowledge shared is helpful? You might want to give our mailing list a try. We'll send you 2-4 emails a month, right when new posts come out.

Hi there! Want some more knowledge?

Think that the knowledge shared is helpful? You might want to give our mailing list a try. We'll send you 2-4 emails a month, right when new posts come out.