Use Logpoints!

There’s sometimes a tribal attitude about how web developers should be debugging their code and solving problems. There’s the console.log loyalists, then there’s the debugger/breakpoint maximalists. I worked on the Firefox DevTools debugger for years and I can tell you my philosophy — use whichever tool helps you get the job done! I use console.log […]

The post Use Logpoints! appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh

There’s sometimes a tribal attitude about how web developers should be debugging their code and solving problems. There’s the console.log loyalists, then there’s the debugger/breakpoint maximalists. I worked on the Firefox DevTools debugger for years and I can tell you my philosophy — use whichever tool helps you get the job done!

I use console.log for very simple problems, other times when I want an audit trail I can analyze after a series of events to spot the problem and share with others. I use breakpoints when I want to halt execution to to see values and the visual state of the UI. One tool you can use to get the best of both worlds is logpoints, a breakpoint-like mechanism in the devtools debugger that logs instead of halts!

To add a logpoint:

  • open the devtools debugger
  • right-click a line number in a JavaScript file,
  • provide the log message accompanied by any variables you’d like in the log:

You have access to all variables in the current context, which you can add to the logpoint message.

You may be asking “why don’t you just add a console.log to your source file manually? Oftentimes you need to debug third party scripts where manually editing the file isn’t possible. Even if you do have access to the source file, you don’t need to do a bunch of console.log cleanup!

Developer tools are always more popular than believe — take full advantage of them!

The post Use Logpoints! appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh


Print Share Comment Cite Upload Translate Updates
APA

David Walsh | Sciencx (2021-03-22T11:22:12+00:00) Use Logpoints!. Retrieved from https://www.scien.cx/2021/03/22/use-logpoints/

MLA
" » Use Logpoints!." David Walsh | Sciencx - Monday March 22, 2021, https://www.scien.cx/2021/03/22/use-logpoints/
HARVARD
David Walsh | Sciencx Monday March 22, 2021 » Use Logpoints!., viewed ,<https://www.scien.cx/2021/03/22/use-logpoints/>
VANCOUVER
David Walsh | Sciencx - » Use Logpoints!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/22/use-logpoints/
CHICAGO
" » Use Logpoints!." David Walsh | Sciencx - Accessed . https://www.scien.cx/2021/03/22/use-logpoints/
IEEE
" » Use Logpoints!." David Walsh | Sciencx [Online]. Available: https://www.scien.cx/2021/03/22/use-logpoints/. [Accessed: ]
rf:citation
» Use Logpoints! | David Walsh | Sciencx | https://www.scien.cx/2021/03/22/use-logpoints/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.