brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Chrome DevTools logpoints log a value without editing your code

Devtools
~/tips/tip-devtools-logpoints

'cart total', total, items.length

Prints a message to the Console each time a line runs, without pausing the page.

I used to add a console.log line, reload, and then forget to remove it. A logpoint does the same job from inside DevTools, so the source file stays untouched.

Open the Sources panel, find the file and right-click the line number column next to the line you care about. Choose Add logpoint and type the message with the same syntax as console.log(message). Press Enter and a pink icon with two dots appears next to the line.

A message can mix text and variables that exist on that line, for example:

'cart total', total, items.length

From then on, every time the browser runs that line, the message shows up in the Console and execution keeps going. A normal breakpoint stops the page, which is awkward in a loop or in a mouse-move handler that fires dozens of times. A logpoint only prints.

It also helps with a file you cannot edit, such as a minified script from a third party. You get the output without keeping a local copy of the file.

One caveat: logpoints live in DevTools, so another browser profile or someone else’s machine will not have them. They are there for you while you debug, and a teammate gets nothing from them unless you describe the line.

Further reading: Chrome DevTools: breakpoints

More Devtools tips Clear site data for one site from Chrome DevTools user.id === 42 $x(path [, startNode]) @media (prefers-color-scheme: dark) { queryObjects(Promise) All Devtools tips (22) All topics

Link