Logpoints
A logpoint is a non-suspending breakpoint that writes debug messages to the console when it is hit.
Logpoints help you with:
Keeping debug logging clean and centralized instead of scattering
print()calls.Getting insight into timing-sensitive sections of the program without pausing execution. Logpoints can be added or modified while the program is running, without restarting it.
Debugging libraries or other code that you cannot edit.
Create logpoints
Click the gutter between any two executable lines. A yellow circle icon appears.
Since the gutter is also used for breakpoints, you can hold a modifier key while clicking to restrict which type is created:
Ctrl: Add breakpoints only
Shift: Add logpoints only
Enter the expression to log. With this expression, you can capture any state that is accessible at this point in the program.
Convert an existing breakpoint to a logpoint
Right-click an existing breakpoint in the gutter, then click More, or press Ctrl+Shift+F8.
Configure the logging options.
Clear the Suspend option if you want the breakpoint to log output without pausing the program. Leave Suspend selected if you want to log output and stop at the same breakpoint.
Logging options
The expression that you enter for a logpoint is stored in the Evaluate and log property of the breakpoint. To also write the breakpoint hit message or the stack trace to the console, use the Log property. For more information, refer to Breakpoints' properties reference.
Narrow the logging
Because logpoints are regular breakpoints with logging options, you can combine them with other breakpoint properties.
- Condition
Add a condition to log output only when a Boolean expression evaluates to
true. The condition needs to be valid at the line where the breakpoint is set.- Dependent breakpoints
A non-suspending breakpoint can act as a trigger for another breakpoint in Disable until hitting the following breakpoint. Use this when a later breakpoint should become active only after a specific code path is reached.
For the complete list of breakpoint properties, refer to Configure breakpoints' properties.
Logpoint icons
Non-suspending breakpoints use a different gutter icon from regular suspending breakpoints.
Line | Exception | |
|---|---|---|
Non-suspending | ||
Verified non-suspending |
Manage logpoints
Logpoints appear in the same Breakpoints dialog as other breakpoints. From there, you can disable, mute, remove, describe, and group them together with the rest of your breakpoint setup.
For more information, refer to Breakpoints.