Skip to content

Implement log breakpoints#1086

Open
lionel- wants to merge 1 commit intofeature/conditional-breakpointsfrom
feature/log-breakpoints
Open

Implement log breakpoints#1086
lionel- wants to merge 1 commit intofeature/conditional-breakpointsfrom
feature/log-breakpoints

Conversation

@lionel-
Copy link
Contributor

@lionel- lionel- commented Mar 5, 2026

Branched from #1064.

Adds support for DAP log breakpoints (logpoints). When a breakpoint has a log message template instead of (or in addition to) a condition, it evaluates the template at hit time, prints the result to the debug console, and does not stop execution. This is the DAP "logpoint" feature.

The log message template uses {expression} placeholders for interpolation, as mandated by the DAP spec. On the R side, interpolation is handled by glue::glue() if we detect a { character. This fails actionnably (message in Console output) if glue is not installed. If there is no { character, the template is returned as is, allowing simple messages to work without the glue dependency.

Log breakpoints respect conditions: if a breakpoint has both a condition and a log message, the condition is evaluated first and the log message only fires when the condition is met. This naturally extends to hit-count breakpoints in the future, since they'll slot into the same pre-check phase. The flow in ps_should_break is now: enabled check → condition evaluation → log-or-stop.

Output is emitted through the same emit_breakpoint_output path as conditional breakpoints, using the ```breakpoint fenced block with a clickable file link. When there's no condition, the condition header line (#> ...) is omitted and only the log message content is shown.

Screenshot 2026-03-05 at 10 43 18

With an error we get:

Screenshot 2026-03-05 at 10 55 23

QA Notes

Tested on the backend side.

To test manually:

foo <- function(x) {
  y <- x * 2
  y + 1
}
for (i in 1:5) {
  foo(i)
}
  1. Set a log breakpoint on y <- x * 2 with message x is {x}, y will be {x * 2}. Run the loop — should see 5 log messages in the console without stopping.
  2. Add a condition x > 3 to the same log breakpoint. Run the loop — should only see messages for x = 4 and x = 5.
  3. Try a log message referencing a nonexistent variable like {nonexistent}: should show an inline error without stopping.
  4. Without glue installed: a log message without glue syntax like checkpoint reached should work. A log message with glue syntax should fail actionably (error in console output).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant