Logpoints for Non-Breaking Inspection
You'll learn how to inspect values during code execution without pausing your program or editing your source files.
What Are Logpoints?
A logpoint is a special kind of breakpoint that logs information to the console instead of pausing execution. Think of it like placing a console.log() statement in your code, but without actually modifying your source file. When execution reaches a logpoint, it outputs the specified message or values, then continues running normally.
Why Use Logpoints?
Sometimes you want to observe what's happening in your code without interrupting the flow. Traditional breakpoints pause execution, which can be disruptive—especially when debugging loops, timers, or event handlers that need continuous execution. Conditional breakpoints (which you just learned) pause when a condition is met, but logpoints give you the observation benefits without any stopping.
Logpoints are perfect when:
- You need to track values over multiple iterations
- Pausing would alter the behavior you're debugging (like timing-sensitive code)
- You want to monitor code in production-like conditions
- You're debugging third-party code you can't easily modify
How Logpoints Work
Set a logpoint the same way you set a conditional breakpoint—right-click the line number in DevTools and choose "Add logpoint." Instead of entering a condition, you enter an expression to log. You can reference variables directly without wrapping them in quotes:
If you type userId, status as your logpoint expression, it logs those variable values each time that line executes, appearing in your console just like console.log(userId, status) would.
Key Takeaway: Logpoints let you observe runtime values and behavior without pausing execution or touching your source code, making them ideal for continuous monitoring during debugging.